google-cloud-kms-v1 1.2.1 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -181,14 +181,26 @@ module Google
181
181
  universe_domain: @config.universe_domain,
182
182
  channel_args: @config.channel_args,
183
183
  interceptors: @config.interceptors,
184
- channel_pool_config: @config.channel_pool
184
+ channel_pool_config: @config.channel_pool,
185
+ logger: @config.logger
185
186
  )
186
187
 
188
+ @autokey_admin_stub.stub_logger&.info do |entry|
189
+ entry.set_system_name
190
+ entry.set_service
191
+ entry.message = "Created client for #{entry.service}"
192
+ entry.set_credentials_fields credentials
193
+ entry.set "customEndpoint", @config.endpoint if @config.endpoint
194
+ entry.set "defaultTimeout", @config.timeout if @config.timeout
195
+ entry.set "quotaProject", @quota_project_id if @quota_project_id
196
+ end
197
+
187
198
  @location_client = Google::Cloud::Location::Locations::Client.new do |config|
188
199
  config.credentials = credentials
189
200
  config.quota_project = @quota_project_id
190
201
  config.endpoint = @autokey_admin_stub.endpoint
191
202
  config.universe_domain = @autokey_admin_stub.universe_domain
203
+ config.logger = @autokey_admin_stub.logger if config.respond_to? :logger=
192
204
  end
193
205
 
194
206
  @iam_policy_client = Google::Iam::V1::IAMPolicy::Client.new do |config|
@@ -196,6 +208,7 @@ module Google
196
208
  config.quota_project = @quota_project_id
197
209
  config.endpoint = @autokey_admin_stub.endpoint
198
210
  config.universe_domain = @autokey_admin_stub.universe_domain
211
+ config.logger = @autokey_admin_stub.logger if config.respond_to? :logger=
199
212
  end
200
213
  end
201
214
 
@@ -213,6 +226,15 @@ module Google
213
226
  #
214
227
  attr_reader :iam_policy_client
215
228
 
229
+ ##
230
+ # The logger used for request/response debug logging.
231
+ #
232
+ # @return [Logger]
233
+ #
234
+ def logger
235
+ @autokey_admin_stub.logger
236
+ end
237
+
216
238
  # Service calls
217
239
 
218
240
  ##
@@ -306,7 +328,6 @@ module Google
306
328
 
307
329
  @autokey_admin_stub.call_rpc :update_autokey_config, request, options: options do |response, operation|
308
330
  yield response, operation if block_given?
309
- return response
310
331
  end
311
332
  rescue ::GRPC::BadStatus => e
312
333
  raise ::Google::Cloud::Error.from_error(e)
@@ -394,7 +415,6 @@ module Google
394
415
 
395
416
  @autokey_admin_stub.call_rpc :get_autokey_config, request, options: options do |response, operation|
396
417
  yield response, operation if block_given?
397
- return response
398
418
  end
399
419
  rescue ::GRPC::BadStatus => e
400
420
  raise ::Google::Cloud::Error.from_error(e)
@@ -482,7 +502,6 @@ module Google
482
502
 
483
503
  @autokey_admin_stub.call_rpc :show_effective_autokey_config, request, options: options do |response, operation|
484
504
  yield response, operation if block_given?
485
- return response
486
505
  end
487
506
  rescue ::GRPC::BadStatus => e
488
507
  raise ::Google::Cloud::Error.from_error(e)
@@ -571,6 +590,11 @@ module Google
571
590
  # default endpoint URL. The default value of nil uses the environment
572
591
  # universe (usually the default "googleapis.com" universe).
573
592
  # @return [::String,nil]
593
+ # @!attribute [rw] logger
594
+ # A custom logger to use for request/response debug logging, or the value
595
+ # `:default` (the default) to construct a default logger, or `nil` to
596
+ # explicitly disable logging.
597
+ # @return [::Logger,:default,nil]
574
598
  #
575
599
  class Configuration
576
600
  extend ::Gapic::Config
@@ -595,6 +619,7 @@ module Google
595
619
  config_attr :retry_policy, nil, ::Hash, ::Proc, nil
596
620
  config_attr :quota_project, nil, ::String, nil
597
621
  config_attr :universe_domain, nil, ::String, nil
622
+ config_attr :logger, :default, ::Logger, nil, :default
598
623
 
599
624
  # @private
600
625
  def initialize parent_config = nil
@@ -174,15 +174,27 @@ module Google
174
174
  endpoint: @config.endpoint,
175
175
  endpoint_template: DEFAULT_ENDPOINT_TEMPLATE,
176
176
  universe_domain: @config.universe_domain,
177
- credentials: credentials
177
+ credentials: credentials,
178
+ logger: @config.logger
178
179
  )
179
180
 
181
+ @autokey_admin_stub.logger(stub: true)&.info do |entry|
182
+ entry.set_system_name
183
+ entry.set_service
184
+ entry.message = "Created client for #{entry.service}"
185
+ entry.set_credentials_fields credentials
186
+ entry.set "customEndpoint", @config.endpoint if @config.endpoint
187
+ entry.set "defaultTimeout", @config.timeout if @config.timeout
188
+ entry.set "quotaProject", @quota_project_id if @quota_project_id
189
+ end
190
+
180
191
  @location_client = Google::Cloud::Location::Locations::Rest::Client.new do |config|
181
192
  config.credentials = credentials
182
193
  config.quota_project = @quota_project_id
183
194
  config.endpoint = @autokey_admin_stub.endpoint
184
195
  config.universe_domain = @autokey_admin_stub.universe_domain
185
196
  config.bindings_override = @config.bindings_override
197
+ config.logger = @autokey_admin_stub.logger if config.respond_to? :logger=
186
198
  end
187
199
 
188
200
  @iam_policy_client = Google::Iam::V1::IAMPolicy::Rest::Client.new do |config|
@@ -191,6 +203,7 @@ module Google
191
203
  config.endpoint = @autokey_admin_stub.endpoint
192
204
  config.universe_domain = @autokey_admin_stub.universe_domain
193
205
  config.bindings_override = @config.bindings_override
206
+ config.logger = @autokey_admin_stub.logger if config.respond_to? :logger=
194
207
  end
195
208
  end
196
209
 
@@ -208,6 +221,15 @@ module Google
208
221
  #
209
222
  attr_reader :iam_policy_client
210
223
 
224
+ ##
225
+ # The logger used for request/response debug logging.
226
+ #
227
+ # @return [Logger]
228
+ #
229
+ def logger
230
+ @autokey_admin_stub.logger
231
+ end
232
+
211
233
  # Service calls
212
234
 
213
235
  ##
@@ -294,7 +316,6 @@ module Google
294
316
 
295
317
  @autokey_admin_stub.update_autokey_config request, options do |result, operation|
296
318
  yield result, operation if block_given?
297
- return result
298
319
  end
299
320
  rescue ::Gapic::Rest::Error => e
300
321
  raise ::Google::Cloud::Error.from_error(e)
@@ -375,7 +396,6 @@ module Google
375
396
 
376
397
  @autokey_admin_stub.get_autokey_config request, options do |result, operation|
377
398
  yield result, operation if block_given?
378
- return result
379
399
  end
380
400
  rescue ::Gapic::Rest::Error => e
381
401
  raise ::Google::Cloud::Error.from_error(e)
@@ -456,7 +476,6 @@ module Google
456
476
 
457
477
  @autokey_admin_stub.show_effective_autokey_config request, options do |result, operation|
458
478
  yield result, operation if block_given?
459
- return result
460
479
  end
461
480
  rescue ::Gapic::Rest::Error => e
462
481
  raise ::Google::Cloud::Error.from_error(e)
@@ -536,6 +555,11 @@ module Google
536
555
  # default endpoint URL. The default value of nil uses the environment
537
556
  # universe (usually the default "googleapis.com" universe).
538
557
  # @return [::String,nil]
558
+ # @!attribute [rw] logger
559
+ # A custom logger to use for request/response debug logging, or the value
560
+ # `:default` (the default) to construct a default logger, or `nil` to
561
+ # explicitly disable logging.
562
+ # @return [::Logger,:default,nil]
539
563
  #
540
564
  class Configuration
541
565
  extend ::Gapic::Config
@@ -564,6 +588,7 @@ module Google
564
588
  # by the host service.
565
589
  # @return [::Hash{::Symbol=>::Array<::Gapic::Rest::GrpcTranscoder::HttpBinding>}]
566
590
  config_attr :bindings_override, {}, ::Hash, nil
591
+ config_attr :logger, :default, ::Logger, nil, :default
567
592
 
568
593
  # @private
569
594
  def initialize parent_config = nil
@@ -30,7 +30,8 @@ module Google
30
30
  # including transcoding, making the REST call, and deserialing the response.
31
31
  #
32
32
  class ServiceStub
33
- def initialize endpoint:, endpoint_template:, universe_domain:, credentials:
33
+ # @private
34
+ def initialize endpoint:, endpoint_template:, universe_domain:, credentials:, logger:
34
35
  # These require statements are intentionally placed here to initialize
35
36
  # the REST modules only when it's required.
36
37
  require "gapic/rest"
@@ -40,7 +41,9 @@ module Google
40
41
  universe_domain: universe_domain,
41
42
  credentials: credentials,
42
43
  numeric_enums: true,
43
- raise_faraday_errors: false
44
+ service_name: self.class,
45
+ raise_faraday_errors: false,
46
+ logger: logger
44
47
  end
45
48
 
46
49
  ##
@@ -61,6 +64,15 @@ module Google
61
64
  @client_stub.endpoint
62
65
  end
63
66
 
67
+ ##
68
+ # The logger used for request/response debug logging.
69
+ #
70
+ # @return [Logger]
71
+ #
72
+ def logger stub: false
73
+ stub ? @client_stub.stub_logger : @client_stub.logger
74
+ end
75
+
64
76
  ##
65
77
  # Baseline implementation for the update_autokey_config REST call
66
78
  #
@@ -87,16 +99,18 @@ module Google
87
99
 
88
100
  response = @client_stub.make_http_request(
89
101
  verb,
90
- uri: uri,
91
- body: body || "",
92
- params: query_string_params,
102
+ uri: uri,
103
+ body: body || "",
104
+ params: query_string_params,
105
+ method_name: "update_autokey_config",
93
106
  options: options
94
107
  )
95
108
  operation = ::Gapic::Rest::TransportOperation.new response
96
109
  result = ::Google::Cloud::Kms::V1::AutokeyConfig.decode_json response.body, ignore_unknown_fields: true
97
-
98
- yield result, operation if block_given?
99
- result
110
+ catch :response do
111
+ yield result, operation if block_given?
112
+ result
113
+ end
100
114
  end
101
115
 
102
116
  ##
@@ -125,16 +139,18 @@ module Google
125
139
 
126
140
  response = @client_stub.make_http_request(
127
141
  verb,
128
- uri: uri,
129
- body: body || "",
130
- params: query_string_params,
142
+ uri: uri,
143
+ body: body || "",
144
+ params: query_string_params,
145
+ method_name: "get_autokey_config",
131
146
  options: options
132
147
  )
133
148
  operation = ::Gapic::Rest::TransportOperation.new response
134
149
  result = ::Google::Cloud::Kms::V1::AutokeyConfig.decode_json response.body, ignore_unknown_fields: true
135
-
136
- yield result, operation if block_given?
137
- result
150
+ catch :response do
151
+ yield result, operation if block_given?
152
+ result
153
+ end
138
154
  end
139
155
 
140
156
  ##
@@ -163,16 +179,18 @@ module Google
163
179
 
164
180
  response = @client_stub.make_http_request(
165
181
  verb,
166
- uri: uri,
167
- body: body || "",
168
- params: query_string_params,
182
+ uri: uri,
183
+ body: body || "",
184
+ params: query_string_params,
185
+ method_name: "show_effective_autokey_config",
169
186
  options: options
170
187
  )
171
188
  operation = ::Gapic::Rest::TransportOperation.new response
172
189
  result = ::Google::Cloud::Kms::V1::ShowEffectiveAutokeyConfigResponse.decode_json response.body, ignore_unknown_fields: true
173
-
174
- yield result, operation if block_given?
175
- result
190
+ catch :response do
191
+ yield result, operation if block_given?
192
+ result
193
+ end
176
194
  end
177
195
 
178
196
  ##
@@ -183,14 +183,26 @@ module Google
183
183
  universe_domain: @config.universe_domain,
184
184
  channel_args: @config.channel_args,
185
185
  interceptors: @config.interceptors,
186
- channel_pool_config: @config.channel_pool
186
+ channel_pool_config: @config.channel_pool,
187
+ logger: @config.logger
187
188
  )
188
189
 
190
+ @ekm_service_stub.stub_logger&.info do |entry|
191
+ entry.set_system_name
192
+ entry.set_service
193
+ entry.message = "Created client for #{entry.service}"
194
+ entry.set_credentials_fields credentials
195
+ entry.set "customEndpoint", @config.endpoint if @config.endpoint
196
+ entry.set "defaultTimeout", @config.timeout if @config.timeout
197
+ entry.set "quotaProject", @quota_project_id if @quota_project_id
198
+ end
199
+
189
200
  @location_client = Google::Cloud::Location::Locations::Client.new do |config|
190
201
  config.credentials = credentials
191
202
  config.quota_project = @quota_project_id
192
203
  config.endpoint = @ekm_service_stub.endpoint
193
204
  config.universe_domain = @ekm_service_stub.universe_domain
205
+ config.logger = @ekm_service_stub.logger if config.respond_to? :logger=
194
206
  end
195
207
 
196
208
  @iam_policy_client = Google::Iam::V1::IAMPolicy::Client.new do |config|
@@ -198,6 +210,7 @@ module Google
198
210
  config.quota_project = @quota_project_id
199
211
  config.endpoint = @ekm_service_stub.endpoint
200
212
  config.universe_domain = @ekm_service_stub.universe_domain
213
+ config.logger = @ekm_service_stub.logger if config.respond_to? :logger=
201
214
  end
202
215
  end
203
216
 
@@ -215,6 +228,15 @@ module Google
215
228
  #
216
229
  attr_reader :iam_policy_client
217
230
 
231
+ ##
232
+ # The logger used for request/response debug logging.
233
+ #
234
+ # @return [Logger]
235
+ #
236
+ def logger
237
+ @ekm_service_stub.logger
238
+ end
239
+
218
240
  # Service calls
219
241
 
220
242
  ##
@@ -325,7 +347,7 @@ module Google
325
347
  @ekm_service_stub.call_rpc :list_ekm_connections, request, options: options do |response, operation|
326
348
  response = ::Gapic::PagedEnumerable.new @ekm_service_stub, :list_ekm_connections, request, response, operation, options
327
349
  yield response, operation if block_given?
328
- return response
350
+ throw :response, response
329
351
  end
330
352
  rescue ::GRPC::BadStatus => e
331
353
  raise ::Google::Cloud::Error.from_error(e)
@@ -413,7 +435,6 @@ module Google
413
435
 
414
436
  @ekm_service_stub.call_rpc :get_ekm_connection, request, options: options do |response, operation|
415
437
  yield response, operation if block_given?
416
- return response
417
438
  end
418
439
  rescue ::GRPC::BadStatus => e
419
440
  raise ::Google::Cloud::Error.from_error(e)
@@ -508,7 +529,6 @@ module Google
508
529
 
509
530
  @ekm_service_stub.call_rpc :create_ekm_connection, request, options: options do |response, operation|
510
531
  yield response, operation if block_given?
511
- return response
512
532
  end
513
533
  rescue ::GRPC::BadStatus => e
514
534
  raise ::Google::Cloud::Error.from_error(e)
@@ -597,7 +617,6 @@ module Google
597
617
 
598
618
  @ekm_service_stub.call_rpc :update_ekm_connection, request, options: options do |response, operation|
599
619
  yield response, operation if block_given?
600
- return response
601
620
  end
602
621
  rescue ::GRPC::BadStatus => e
603
622
  raise ::Google::Cloud::Error.from_error(e)
@@ -685,7 +704,6 @@ module Google
685
704
 
686
705
  @ekm_service_stub.call_rpc :get_ekm_config, request, options: options do |response, operation|
687
706
  yield response, operation if block_given?
688
- return response
689
707
  end
690
708
  rescue ::GRPC::BadStatus => e
691
709
  raise ::Google::Cloud::Error.from_error(e)
@@ -774,7 +792,6 @@ module Google
774
792
 
775
793
  @ekm_service_stub.call_rpc :update_ekm_config, request, options: options do |response, operation|
776
794
  yield response, operation if block_given?
777
- return response
778
795
  end
779
796
  rescue ::GRPC::BadStatus => e
780
797
  raise ::Google::Cloud::Error.from_error(e)
@@ -865,7 +882,6 @@ module Google
865
882
 
866
883
  @ekm_service_stub.call_rpc :verify_connectivity, request, options: options do |response, operation|
867
884
  yield response, operation if block_given?
868
- return response
869
885
  end
870
886
  rescue ::GRPC::BadStatus => e
871
887
  raise ::Google::Cloud::Error.from_error(e)
@@ -954,6 +970,11 @@ module Google
954
970
  # default endpoint URL. The default value of nil uses the environment
955
971
  # universe (usually the default "googleapis.com" universe).
956
972
  # @return [::String,nil]
973
+ # @!attribute [rw] logger
974
+ # A custom logger to use for request/response debug logging, or the value
975
+ # `:default` (the default) to construct a default logger, or `nil` to
976
+ # explicitly disable logging.
977
+ # @return [::Logger,:default,nil]
957
978
  #
958
979
  class Configuration
959
980
  extend ::Gapic::Config
@@ -978,6 +999,7 @@ module Google
978
999
  config_attr :retry_policy, nil, ::Hash, ::Proc, nil
979
1000
  config_attr :quota_project, nil, ::String, nil
980
1001
  config_attr :universe_domain, nil, ::String, nil
1002
+ config_attr :logger, :default, ::Logger, nil, :default
981
1003
 
982
1004
  # @private
983
1005
  def initialize parent_config = nil
@@ -176,15 +176,27 @@ module Google
176
176
  endpoint: @config.endpoint,
177
177
  endpoint_template: DEFAULT_ENDPOINT_TEMPLATE,
178
178
  universe_domain: @config.universe_domain,
179
- credentials: credentials
179
+ credentials: credentials,
180
+ logger: @config.logger
180
181
  )
181
182
 
183
+ @ekm_service_stub.logger(stub: true)&.info do |entry|
184
+ entry.set_system_name
185
+ entry.set_service
186
+ entry.message = "Created client for #{entry.service}"
187
+ entry.set_credentials_fields credentials
188
+ entry.set "customEndpoint", @config.endpoint if @config.endpoint
189
+ entry.set "defaultTimeout", @config.timeout if @config.timeout
190
+ entry.set "quotaProject", @quota_project_id if @quota_project_id
191
+ end
192
+
182
193
  @location_client = Google::Cloud::Location::Locations::Rest::Client.new do |config|
183
194
  config.credentials = credentials
184
195
  config.quota_project = @quota_project_id
185
196
  config.endpoint = @ekm_service_stub.endpoint
186
197
  config.universe_domain = @ekm_service_stub.universe_domain
187
198
  config.bindings_override = @config.bindings_override
199
+ config.logger = @ekm_service_stub.logger if config.respond_to? :logger=
188
200
  end
189
201
 
190
202
  @iam_policy_client = Google::Iam::V1::IAMPolicy::Rest::Client.new do |config|
@@ -193,6 +205,7 @@ module Google
193
205
  config.endpoint = @ekm_service_stub.endpoint
194
206
  config.universe_domain = @ekm_service_stub.universe_domain
195
207
  config.bindings_override = @config.bindings_override
208
+ config.logger = @ekm_service_stub.logger if config.respond_to? :logger=
196
209
  end
197
210
  end
198
211
 
@@ -210,6 +223,15 @@ module Google
210
223
  #
211
224
  attr_reader :iam_policy_client
212
225
 
226
+ ##
227
+ # The logger used for request/response debug logging.
228
+ #
229
+ # @return [Logger]
230
+ #
231
+ def logger
232
+ @ekm_service_stub.logger
233
+ end
234
+
213
235
  # Service calls
214
236
 
215
237
  ##
@@ -313,7 +335,7 @@ module Google
313
335
  @ekm_service_stub.list_ekm_connections request, options do |result, operation|
314
336
  result = ::Gapic::Rest::PagedEnumerable.new @ekm_service_stub, :list_ekm_connections, "ekm_connections", request, result, options
315
337
  yield result, operation if block_given?
316
- return result
338
+ throw :response, result
317
339
  end
318
340
  rescue ::Gapic::Rest::Error => e
319
341
  raise ::Google::Cloud::Error.from_error(e)
@@ -394,7 +416,6 @@ module Google
394
416
 
395
417
  @ekm_service_stub.get_ekm_connection request, options do |result, operation|
396
418
  yield result, operation if block_given?
397
- return result
398
419
  end
399
420
  rescue ::Gapic::Rest::Error => e
400
421
  raise ::Google::Cloud::Error.from_error(e)
@@ -482,7 +503,6 @@ module Google
482
503
 
483
504
  @ekm_service_stub.create_ekm_connection request, options do |result, operation|
484
505
  yield result, operation if block_given?
485
- return result
486
506
  end
487
507
  rescue ::Gapic::Rest::Error => e
488
508
  raise ::Google::Cloud::Error.from_error(e)
@@ -564,7 +584,6 @@ module Google
564
584
 
565
585
  @ekm_service_stub.update_ekm_connection request, options do |result, operation|
566
586
  yield result, operation if block_given?
567
- return result
568
587
  end
569
588
  rescue ::Gapic::Rest::Error => e
570
589
  raise ::Google::Cloud::Error.from_error(e)
@@ -645,7 +664,6 @@ module Google
645
664
 
646
665
  @ekm_service_stub.get_ekm_config request, options do |result, operation|
647
666
  yield result, operation if block_given?
648
- return result
649
667
  end
650
668
  rescue ::Gapic::Rest::Error => e
651
669
  raise ::Google::Cloud::Error.from_error(e)
@@ -727,7 +745,6 @@ module Google
727
745
 
728
746
  @ekm_service_stub.update_ekm_config request, options do |result, operation|
729
747
  yield result, operation if block_given?
730
- return result
731
748
  end
732
749
  rescue ::Gapic::Rest::Error => e
733
750
  raise ::Google::Cloud::Error.from_error(e)
@@ -811,7 +828,6 @@ module Google
811
828
 
812
829
  @ekm_service_stub.verify_connectivity request, options do |result, operation|
813
830
  yield result, operation if block_given?
814
- return result
815
831
  end
816
832
  rescue ::Gapic::Rest::Error => e
817
833
  raise ::Google::Cloud::Error.from_error(e)
@@ -891,6 +907,11 @@ module Google
891
907
  # default endpoint URL. The default value of nil uses the environment
892
908
  # universe (usually the default "googleapis.com" universe).
893
909
  # @return [::String,nil]
910
+ # @!attribute [rw] logger
911
+ # A custom logger to use for request/response debug logging, or the value
912
+ # `:default` (the default) to construct a default logger, or `nil` to
913
+ # explicitly disable logging.
914
+ # @return [::Logger,:default,nil]
894
915
  #
895
916
  class Configuration
896
917
  extend ::Gapic::Config
@@ -919,6 +940,7 @@ module Google
919
940
  # by the host service.
920
941
  # @return [::Hash{::Symbol=>::Array<::Gapic::Rest::GrpcTranscoder::HttpBinding>}]
921
942
  config_attr :bindings_override, {}, ::Hash, nil
943
+ config_attr :logger, :default, ::Logger, nil, :default
922
944
 
923
945
  # @private
924
946
  def initialize parent_config = nil