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.
@@ -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 list_ekm_connections 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: "list_ekm_connections",
93
106
  options: options
94
107
  )
95
108
  operation = ::Gapic::Rest::TransportOperation.new response
96
109
  result = ::Google::Cloud::Kms::V1::ListEkmConnectionsResponse.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_ekm_connection",
131
146
  options: options
132
147
  )
133
148
  operation = ::Gapic::Rest::TransportOperation.new response
134
149
  result = ::Google::Cloud::Kms::V1::EkmConnection.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: "create_ekm_connection",
169
186
  options: options
170
187
  )
171
188
  operation = ::Gapic::Rest::TransportOperation.new response
172
189
  result = ::Google::Cloud::Kms::V1::EkmConnection.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
  ##
@@ -201,16 +219,18 @@ module Google
201
219
 
202
220
  response = @client_stub.make_http_request(
203
221
  verb,
204
- uri: uri,
205
- body: body || "",
206
- params: query_string_params,
222
+ uri: uri,
223
+ body: body || "",
224
+ params: query_string_params,
225
+ method_name: "update_ekm_connection",
207
226
  options: options
208
227
  )
209
228
  operation = ::Gapic::Rest::TransportOperation.new response
210
229
  result = ::Google::Cloud::Kms::V1::EkmConnection.decode_json response.body, ignore_unknown_fields: true
211
-
212
- yield result, operation if block_given?
213
- result
230
+ catch :response do
231
+ yield result, operation if block_given?
232
+ result
233
+ end
214
234
  end
215
235
 
216
236
  ##
@@ -239,16 +259,18 @@ module Google
239
259
 
240
260
  response = @client_stub.make_http_request(
241
261
  verb,
242
- uri: uri,
243
- body: body || "",
244
- params: query_string_params,
262
+ uri: uri,
263
+ body: body || "",
264
+ params: query_string_params,
265
+ method_name: "get_ekm_config",
245
266
  options: options
246
267
  )
247
268
  operation = ::Gapic::Rest::TransportOperation.new response
248
269
  result = ::Google::Cloud::Kms::V1::EkmConfig.decode_json response.body, ignore_unknown_fields: true
249
-
250
- yield result, operation if block_given?
251
- result
270
+ catch :response do
271
+ yield result, operation if block_given?
272
+ result
273
+ end
252
274
  end
253
275
 
254
276
  ##
@@ -277,16 +299,18 @@ module Google
277
299
 
278
300
  response = @client_stub.make_http_request(
279
301
  verb,
280
- uri: uri,
281
- body: body || "",
282
- params: query_string_params,
302
+ uri: uri,
303
+ body: body || "",
304
+ params: query_string_params,
305
+ method_name: "update_ekm_config",
283
306
  options: options
284
307
  )
285
308
  operation = ::Gapic::Rest::TransportOperation.new response
286
309
  result = ::Google::Cloud::Kms::V1::EkmConfig.decode_json response.body, ignore_unknown_fields: true
287
-
288
- yield result, operation if block_given?
289
- result
310
+ catch :response do
311
+ yield result, operation if block_given?
312
+ result
313
+ end
290
314
  end
291
315
 
292
316
  ##
@@ -315,16 +339,18 @@ module Google
315
339
 
316
340
  response = @client_stub.make_http_request(
317
341
  verb,
318
- uri: uri,
319
- body: body || "",
320
- params: query_string_params,
342
+ uri: uri,
343
+ body: body || "",
344
+ params: query_string_params,
345
+ method_name: "verify_connectivity",
321
346
  options: options
322
347
  )
323
348
  operation = ::Gapic::Rest::TransportOperation.new response
324
349
  result = ::Google::Cloud::Kms::V1::VerifyConnectivityResponse.decode_json response.body, ignore_unknown_fields: true
325
-
326
- yield result, operation if block_given?
327
- result
350
+ catch :response do
351
+ yield result, operation if block_given?
352
+ result
353
+ end
328
354
  end
329
355
 
330
356
  ##
@@ -294,14 +294,26 @@ module Google
294
294
  universe_domain: @config.universe_domain,
295
295
  channel_args: @config.channel_args,
296
296
  interceptors: @config.interceptors,
297
- channel_pool_config: @config.channel_pool
297
+ channel_pool_config: @config.channel_pool,
298
+ logger: @config.logger
298
299
  )
299
300
 
301
+ @key_management_service_stub.stub_logger&.info do |entry|
302
+ entry.set_system_name
303
+ entry.set_service
304
+ entry.message = "Created client for #{entry.service}"
305
+ entry.set_credentials_fields credentials
306
+ entry.set "customEndpoint", @config.endpoint if @config.endpoint
307
+ entry.set "defaultTimeout", @config.timeout if @config.timeout
308
+ entry.set "quotaProject", @quota_project_id if @quota_project_id
309
+ end
310
+
300
311
  @location_client = Google::Cloud::Location::Locations::Client.new do |config|
301
312
  config.credentials = credentials
302
313
  config.quota_project = @quota_project_id
303
314
  config.endpoint = @key_management_service_stub.endpoint
304
315
  config.universe_domain = @key_management_service_stub.universe_domain
316
+ config.logger = @key_management_service_stub.logger if config.respond_to? :logger=
305
317
  end
306
318
 
307
319
  @iam_policy_client = Google::Iam::V1::IAMPolicy::Client.new do |config|
@@ -309,6 +321,7 @@ module Google
309
321
  config.quota_project = @quota_project_id
310
322
  config.endpoint = @key_management_service_stub.endpoint
311
323
  config.universe_domain = @key_management_service_stub.universe_domain
324
+ config.logger = @key_management_service_stub.logger if config.respond_to? :logger=
312
325
  end
313
326
  end
314
327
 
@@ -326,6 +339,15 @@ module Google
326
339
  #
327
340
  attr_reader :iam_policy_client
328
341
 
342
+ ##
343
+ # The logger used for request/response debug logging.
344
+ #
345
+ # @return [Logger]
346
+ #
347
+ def logger
348
+ @key_management_service_stub.logger
349
+ end
350
+
329
351
  # Service calls
330
352
 
331
353
  ##
@@ -436,7 +458,7 @@ module Google
436
458
  @key_management_service_stub.call_rpc :list_key_rings, request, options: options do |response, operation|
437
459
  response = ::Gapic::PagedEnumerable.new @key_management_service_stub, :list_key_rings, request, response, operation, options
438
460
  yield response, operation if block_given?
439
- return response
461
+ throw :response, response
440
462
  end
441
463
  rescue ::GRPC::BadStatus => e
442
464
  raise ::Google::Cloud::Error.from_error(e)
@@ -551,7 +573,7 @@ module Google
551
573
  @key_management_service_stub.call_rpc :list_crypto_keys, request, options: options do |response, operation|
552
574
  response = ::Gapic::PagedEnumerable.new @key_management_service_stub, :list_crypto_keys, request, response, operation, options
553
575
  yield response, operation if block_given?
554
- return response
576
+ throw :response, response
555
577
  end
556
578
  rescue ::GRPC::BadStatus => e
557
579
  raise ::Google::Cloud::Error.from_error(e)
@@ -667,7 +689,7 @@ module Google
667
689
  @key_management_service_stub.call_rpc :list_crypto_key_versions, request, options: options do |response, operation|
668
690
  response = ::Gapic::PagedEnumerable.new @key_management_service_stub, :list_crypto_key_versions, request, response, operation, options
669
691
  yield response, operation if block_given?
670
- return response
692
+ throw :response, response
671
693
  end
672
694
  rescue ::GRPC::BadStatus => e
673
695
  raise ::Google::Cloud::Error.from_error(e)
@@ -780,7 +802,7 @@ module Google
780
802
  @key_management_service_stub.call_rpc :list_import_jobs, request, options: options do |response, operation|
781
803
  response = ::Gapic::PagedEnumerable.new @key_management_service_stub, :list_import_jobs, request, response, operation, options
782
804
  yield response, operation if block_given?
783
- return response
805
+ throw :response, response
784
806
  end
785
807
  rescue ::GRPC::BadStatus => e
786
808
  raise ::Google::Cloud::Error.from_error(e)
@@ -867,7 +889,6 @@ module Google
867
889
 
868
890
  @key_management_service_stub.call_rpc :get_key_ring, request, options: options do |response, operation|
869
891
  yield response, operation if block_given?
870
- return response
871
892
  end
872
893
  rescue ::GRPC::BadStatus => e
873
894
  raise ::Google::Cloud::Error.from_error(e)
@@ -956,7 +977,6 @@ module Google
956
977
 
957
978
  @key_management_service_stub.call_rpc :get_crypto_key, request, options: options do |response, operation|
958
979
  yield response, operation if block_given?
959
- return response
960
980
  end
961
981
  rescue ::GRPC::BadStatus => e
962
982
  raise ::Google::Cloud::Error.from_error(e)
@@ -1044,7 +1064,6 @@ module Google
1044
1064
 
1045
1065
  @key_management_service_stub.call_rpc :get_crypto_key_version, request, options: options do |response, operation|
1046
1066
  yield response, operation if block_given?
1047
- return response
1048
1067
  end
1049
1068
  rescue ::GRPC::BadStatus => e
1050
1069
  raise ::Google::Cloud::Error.from_error(e)
@@ -1136,7 +1155,6 @@ module Google
1136
1155
 
1137
1156
  @key_management_service_stub.call_rpc :get_public_key, request, options: options do |response, operation|
1138
1157
  yield response, operation if block_given?
1139
- return response
1140
1158
  end
1141
1159
  rescue ::GRPC::BadStatus => e
1142
1160
  raise ::Google::Cloud::Error.from_error(e)
@@ -1223,7 +1241,6 @@ module Google
1223
1241
 
1224
1242
  @key_management_service_stub.call_rpc :get_import_job, request, options: options do |response, operation|
1225
1243
  yield response, operation if block_given?
1226
- return response
1227
1244
  end
1228
1245
  rescue ::GRPC::BadStatus => e
1229
1246
  raise ::Google::Cloud::Error.from_error(e)
@@ -1318,7 +1335,6 @@ module Google
1318
1335
 
1319
1336
  @key_management_service_stub.call_rpc :create_key_ring, request, options: options do |response, operation|
1320
1337
  yield response, operation if block_given?
1321
- return response
1322
1338
  end
1323
1339
  rescue ::GRPC::BadStatus => e
1324
1340
  raise ::Google::Cloud::Error.from_error(e)
@@ -1425,7 +1441,6 @@ module Google
1425
1441
 
1426
1442
  @key_management_service_stub.call_rpc :create_crypto_key, request, options: options do |response, operation|
1427
1443
  yield response, operation if block_given?
1428
- return response
1429
1444
  end
1430
1445
  rescue ::GRPC::BadStatus => e
1431
1446
  raise ::Google::Cloud::Error.from_error(e)
@@ -1521,7 +1536,6 @@ module Google
1521
1536
 
1522
1537
  @key_management_service_stub.call_rpc :create_crypto_key_version, request, options: options do |response, operation|
1523
1538
  yield response, operation if block_given?
1524
- return response
1525
1539
  end
1526
1540
  rescue ::GRPC::BadStatus => e
1527
1541
  raise ::Google::Cloud::Error.from_error(e)
@@ -1694,7 +1708,6 @@ module Google
1694
1708
 
1695
1709
  @key_management_service_stub.call_rpc :import_crypto_key_version, request, options: options do |response, operation|
1696
1710
  yield response, operation if block_given?
1697
- return response
1698
1711
  end
1699
1712
  rescue ::GRPC::BadStatus => e
1700
1713
  raise ::Google::Cloud::Error.from_error(e)
@@ -1792,7 +1805,6 @@ module Google
1792
1805
 
1793
1806
  @key_management_service_stub.call_rpc :create_import_job, request, options: options do |response, operation|
1794
1807
  yield response, operation if block_given?
1795
- return response
1796
1808
  end
1797
1809
  rescue ::GRPC::BadStatus => e
1798
1810
  raise ::Google::Cloud::Error.from_error(e)
@@ -1880,7 +1892,6 @@ module Google
1880
1892
 
1881
1893
  @key_management_service_stub.call_rpc :update_crypto_key, request, options: options do |response, operation|
1882
1894
  yield response, operation if block_given?
1883
- return response
1884
1895
  end
1885
1896
  rescue ::GRPC::BadStatus => e
1886
1897
  raise ::Google::Cloud::Error.from_error(e)
@@ -1980,7 +1991,6 @@ module Google
1980
1991
 
1981
1992
  @key_management_service_stub.call_rpc :update_crypto_key_version, request, options: options do |response, operation|
1982
1993
  yield response, operation if block_given?
1983
- return response
1984
1994
  end
1985
1995
  rescue ::GRPC::BadStatus => e
1986
1996
  raise ::Google::Cloud::Error.from_error(e)
@@ -2075,7 +2085,6 @@ module Google
2075
2085
 
2076
2086
  @key_management_service_stub.call_rpc :update_crypto_key_primary_version, request, options: options do |response, operation|
2077
2087
  yield response, operation if block_given?
2078
- return response
2079
2088
  end
2080
2089
  rescue ::GRPC::BadStatus => e
2081
2090
  raise ::Google::Cloud::Error.from_error(e)
@@ -2182,7 +2191,6 @@ module Google
2182
2191
 
2183
2192
  @key_management_service_stub.call_rpc :destroy_crypto_key_version, request, options: options do |response, operation|
2184
2193
  yield response, operation if block_given?
2185
- return response
2186
2194
  end
2187
2195
  rescue ::GRPC::BadStatus => e
2188
2196
  raise ::Google::Cloud::Error.from_error(e)
@@ -2277,7 +2285,6 @@ module Google
2277
2285
 
2278
2286
  @key_management_service_stub.call_rpc :restore_crypto_key_version, request, options: options do |response, operation|
2279
2287
  yield response, operation if block_given?
2280
- return response
2281
2288
  end
2282
2289
  rescue ::GRPC::BadStatus => e
2283
2290
  raise ::Google::Cloud::Error.from_error(e)
@@ -2438,7 +2445,6 @@ module Google
2438
2445
 
2439
2446
  @key_management_service_stub.call_rpc :encrypt, request, options: options do |response, operation|
2440
2447
  yield response, operation if block_given?
2441
- return response
2442
2448
  end
2443
2449
  rescue ::GRPC::BadStatus => e
2444
2450
  raise ::Google::Cloud::Error.from_error(e)
@@ -2575,7 +2581,6 @@ module Google
2575
2581
 
2576
2582
  @key_management_service_stub.call_rpc :decrypt, request, options: options do |response, operation|
2577
2583
  yield response, operation if block_given?
2578
- return response
2579
2584
  end
2580
2585
  rescue ::GRPC::BadStatus => e
2581
2586
  raise ::Google::Cloud::Error.from_error(e)
@@ -2749,7 +2754,6 @@ module Google
2749
2754
 
2750
2755
  @key_management_service_stub.call_rpc :raw_encrypt, request, options: options do |response, operation|
2751
2756
  yield response, operation if block_given?
2752
- return response
2753
2757
  end
2754
2758
  rescue ::GRPC::BadStatus => e
2755
2759
  raise ::Google::Cloud::Error.from_error(e)
@@ -2903,7 +2907,6 @@ module Google
2903
2907
 
2904
2908
  @key_management_service_stub.call_rpc :raw_decrypt, request, options: options do |response, operation|
2905
2909
  yield response, operation if block_given?
2906
- return response
2907
2910
  end
2908
2911
  rescue ::GRPC::BadStatus => e
2909
2912
  raise ::Google::Cloud::Error.from_error(e)
@@ -3048,7 +3051,6 @@ module Google
3048
3051
 
3049
3052
  @key_management_service_stub.call_rpc :asymmetric_sign, request, options: options do |response, operation|
3050
3053
  yield response, operation if block_given?
3051
- return response
3052
3054
  end
3053
3055
  rescue ::GRPC::BadStatus => e
3054
3056
  raise ::Google::Cloud::Error.from_error(e)
@@ -3164,7 +3166,6 @@ module Google
3164
3166
 
3165
3167
  @key_management_service_stub.call_rpc :asymmetric_decrypt, request, options: options do |response, operation|
3166
3168
  yield response, operation if block_given?
3167
- return response
3168
3169
  end
3169
3170
  rescue ::GRPC::BadStatus => e
3170
3171
  raise ::Google::Cloud::Error.from_error(e)
@@ -3275,7 +3276,6 @@ module Google
3275
3276
 
3276
3277
  @key_management_service_stub.call_rpc :mac_sign, request, options: options do |response, operation|
3277
3278
  yield response, operation if block_given?
3278
- return response
3279
3279
  end
3280
3280
  rescue ::GRPC::BadStatus => e
3281
3281
  raise ::Google::Cloud::Error.from_error(e)
@@ -3408,7 +3408,6 @@ module Google
3408
3408
 
3409
3409
  @key_management_service_stub.call_rpc :mac_verify, request, options: options do |response, operation|
3410
3410
  yield response, operation if block_given?
3411
- return response
3412
3411
  end
3413
3412
  rescue ::GRPC::BadStatus => e
3414
3413
  raise ::Google::Cloud::Error.from_error(e)
@@ -3504,7 +3503,6 @@ module Google
3504
3503
 
3505
3504
  @key_management_service_stub.call_rpc :generate_random_bytes, request, options: options do |response, operation|
3506
3505
  yield response, operation if block_given?
3507
- return response
3508
3506
  end
3509
3507
  rescue ::GRPC::BadStatus => e
3510
3508
  raise ::Google::Cloud::Error.from_error(e)
@@ -3593,6 +3591,11 @@ module Google
3593
3591
  # default endpoint URL. The default value of nil uses the environment
3594
3592
  # universe (usually the default "googleapis.com" universe).
3595
3593
  # @return [::String,nil]
3594
+ # @!attribute [rw] logger
3595
+ # A custom logger to use for request/response debug logging, or the value
3596
+ # `:default` (the default) to construct a default logger, or `nil` to
3597
+ # explicitly disable logging.
3598
+ # @return [::Logger,:default,nil]
3596
3599
  #
3597
3600
  class Configuration
3598
3601
  extend ::Gapic::Config
@@ -3617,6 +3620,7 @@ module Google
3617
3620
  config_attr :retry_policy, nil, ::Hash, ::Proc, nil
3618
3621
  config_attr :quota_project, nil, ::String, nil
3619
3622
  config_attr :universe_domain, nil, ::String, nil
3623
+ config_attr :logger, :default, ::Logger, nil, :default
3620
3624
 
3621
3625
  # @private
3622
3626
  def initialize parent_config = nil