google-cloud-kms-v1 1.2.1 → 1.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -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)
@@ -1571,7 +1585,9 @@ module Google
1571
1585
  # {::Google::Cloud::Kms::V1::CryptoKeyVersion CryptoKeyVersion}, the
1572
1586
  # {::Google::Cloud::Kms::V1::CryptoKeyVersion CryptoKeyVersion} must be a child of
1573
1587
  # {::Google::Cloud::Kms::V1::ImportCryptoKeyVersionRequest#parent ImportCryptoKeyVersionRequest.parent},
1574
- # have been previously created via [ImportCryptoKeyVersion][], and be in
1588
+ # have been previously created via
1589
+ # {::Google::Cloud::Kms::V1::KeyManagementService::Client#import_crypto_key_version ImportCryptoKeyVersion},
1590
+ # and be in
1575
1591
  # {::Google::Cloud::Kms::V1::CryptoKeyVersion::CryptoKeyVersionState::DESTROYED DESTROYED}
1576
1592
  # or
1577
1593
  # {::Google::Cloud::Kms::V1::CryptoKeyVersion::CryptoKeyVersionState::IMPORT_FAILED IMPORT_FAILED}
@@ -1694,7 +1710,6 @@ module Google
1694
1710
 
1695
1711
  @key_management_service_stub.call_rpc :import_crypto_key_version, request, options: options do |response, operation|
1696
1712
  yield response, operation if block_given?
1697
- return response
1698
1713
  end
1699
1714
  rescue ::GRPC::BadStatus => e
1700
1715
  raise ::Google::Cloud::Error.from_error(e)
@@ -1792,7 +1807,6 @@ module Google
1792
1807
 
1793
1808
  @key_management_service_stub.call_rpc :create_import_job, request, options: options do |response, operation|
1794
1809
  yield response, operation if block_given?
1795
- return response
1796
1810
  end
1797
1811
  rescue ::GRPC::BadStatus => e
1798
1812
  raise ::Google::Cloud::Error.from_error(e)
@@ -1880,7 +1894,6 @@ module Google
1880
1894
 
1881
1895
  @key_management_service_stub.call_rpc :update_crypto_key, request, options: options do |response, operation|
1882
1896
  yield response, operation if block_given?
1883
- return response
1884
1897
  end
1885
1898
  rescue ::GRPC::BadStatus => e
1886
1899
  raise ::Google::Cloud::Error.from_error(e)
@@ -1980,7 +1993,6 @@ module Google
1980
1993
 
1981
1994
  @key_management_service_stub.call_rpc :update_crypto_key_version, request, options: options do |response, operation|
1982
1995
  yield response, operation if block_given?
1983
- return response
1984
1996
  end
1985
1997
  rescue ::GRPC::BadStatus => e
1986
1998
  raise ::Google::Cloud::Error.from_error(e)
@@ -2075,7 +2087,6 @@ module Google
2075
2087
 
2076
2088
  @key_management_service_stub.call_rpc :update_crypto_key_primary_version, request, options: options do |response, operation|
2077
2089
  yield response, operation if block_given?
2078
- return response
2079
2090
  end
2080
2091
  rescue ::GRPC::BadStatus => e
2081
2092
  raise ::Google::Cloud::Error.from_error(e)
@@ -2182,7 +2193,6 @@ module Google
2182
2193
 
2183
2194
  @key_management_service_stub.call_rpc :destroy_crypto_key_version, request, options: options do |response, operation|
2184
2195
  yield response, operation if block_given?
2185
- return response
2186
2196
  end
2187
2197
  rescue ::GRPC::BadStatus => e
2188
2198
  raise ::Google::Cloud::Error.from_error(e)
@@ -2277,7 +2287,6 @@ module Google
2277
2287
 
2278
2288
  @key_management_service_stub.call_rpc :restore_crypto_key_version, request, options: options do |response, operation|
2279
2289
  yield response, operation if block_given?
2280
- return response
2281
2290
  end
2282
2291
  rescue ::GRPC::BadStatus => e
2283
2292
  raise ::Google::Cloud::Error.from_error(e)
@@ -2438,7 +2447,6 @@ module Google
2438
2447
 
2439
2448
  @key_management_service_stub.call_rpc :encrypt, request, options: options do |response, operation|
2440
2449
  yield response, operation if block_given?
2441
- return response
2442
2450
  end
2443
2451
  rescue ::GRPC::BadStatus => e
2444
2452
  raise ::Google::Cloud::Error.from_error(e)
@@ -2575,7 +2583,6 @@ module Google
2575
2583
 
2576
2584
  @key_management_service_stub.call_rpc :decrypt, request, options: options do |response, operation|
2577
2585
  yield response, operation if block_given?
2578
- return response
2579
2586
  end
2580
2587
  rescue ::GRPC::BadStatus => e
2581
2588
  raise ::Google::Cloud::Error.from_error(e)
@@ -2749,7 +2756,6 @@ module Google
2749
2756
 
2750
2757
  @key_management_service_stub.call_rpc :raw_encrypt, request, options: options do |response, operation|
2751
2758
  yield response, operation if block_given?
2752
- return response
2753
2759
  end
2754
2760
  rescue ::GRPC::BadStatus => e
2755
2761
  raise ::Google::Cloud::Error.from_error(e)
@@ -2903,7 +2909,6 @@ module Google
2903
2909
 
2904
2910
  @key_management_service_stub.call_rpc :raw_decrypt, request, options: options do |response, operation|
2905
2911
  yield response, operation if block_given?
2906
- return response
2907
2912
  end
2908
2913
  rescue ::GRPC::BadStatus => e
2909
2914
  raise ::Google::Cloud::Error.from_error(e)
@@ -3048,7 +3053,6 @@ module Google
3048
3053
 
3049
3054
  @key_management_service_stub.call_rpc :asymmetric_sign, request, options: options do |response, operation|
3050
3055
  yield response, operation if block_given?
3051
- return response
3052
3056
  end
3053
3057
  rescue ::GRPC::BadStatus => e
3054
3058
  raise ::Google::Cloud::Error.from_error(e)
@@ -3164,7 +3168,6 @@ module Google
3164
3168
 
3165
3169
  @key_management_service_stub.call_rpc :asymmetric_decrypt, request, options: options do |response, operation|
3166
3170
  yield response, operation if block_given?
3167
- return response
3168
3171
  end
3169
3172
  rescue ::GRPC::BadStatus => e
3170
3173
  raise ::Google::Cloud::Error.from_error(e)
@@ -3275,7 +3278,6 @@ module Google
3275
3278
 
3276
3279
  @key_management_service_stub.call_rpc :mac_sign, request, options: options do |response, operation|
3277
3280
  yield response, operation if block_given?
3278
- return response
3279
3281
  end
3280
3282
  rescue ::GRPC::BadStatus => e
3281
3283
  raise ::Google::Cloud::Error.from_error(e)
@@ -3340,7 +3342,8 @@ module Google
3340
3342
  # checksum. {::Google::Cloud::Kms::V1::KeyManagementService::Client KeyManagementService}
3341
3343
  # will report an error if the checksum verification fails. If you receive a
3342
3344
  # checksum error, your client should verify that
3343
- # CRC32C([MacVerifyRequest.tag][]) is equal to
3345
+ # CRC32C({::Google::Cloud::Kms::V1::MacVerifyRequest#mac MacVerifyRequest.mac}) is
3346
+ # equal to
3344
3347
  # {::Google::Cloud::Kms::V1::MacVerifyRequest#mac_crc32c MacVerifyRequest.mac_crc32c},
3345
3348
  # and if so, perform a limited number of retries. A persistent mismatch may
3346
3349
  # indicate an issue in your computation of the CRC32C checksum. Note: This
@@ -3408,7 +3411,6 @@ module Google
3408
3411
 
3409
3412
  @key_management_service_stub.call_rpc :mac_verify, request, options: options do |response, operation|
3410
3413
  yield response, operation if block_given?
3411
- return response
3412
3414
  end
3413
3415
  rescue ::GRPC::BadStatus => e
3414
3416
  raise ::Google::Cloud::Error.from_error(e)
@@ -3504,7 +3506,6 @@ module Google
3504
3506
 
3505
3507
  @key_management_service_stub.call_rpc :generate_random_bytes, request, options: options do |response, operation|
3506
3508
  yield response, operation if block_given?
3507
- return response
3508
3509
  end
3509
3510
  rescue ::GRPC::BadStatus => e
3510
3511
  raise ::Google::Cloud::Error.from_error(e)
@@ -3593,6 +3594,11 @@ module Google
3593
3594
  # default endpoint URL. The default value of nil uses the environment
3594
3595
  # universe (usually the default "googleapis.com" universe).
3595
3596
  # @return [::String,nil]
3597
+ # @!attribute [rw] logger
3598
+ # A custom logger to use for request/response debug logging, or the value
3599
+ # `:default` (the default) to construct a default logger, or `nil` to
3600
+ # explicitly disable logging.
3601
+ # @return [::Logger,:default,nil]
3596
3602
  #
3597
3603
  class Configuration
3598
3604
  extend ::Gapic::Config
@@ -3617,6 +3623,7 @@ module Google
3617
3623
  config_attr :retry_policy, nil, ::Hash, ::Proc, nil
3618
3624
  config_attr :quota_project, nil, ::String, nil
3619
3625
  config_attr :universe_domain, nil, ::String, nil
3626
+ config_attr :logger, :default, ::Logger, nil, :default
3620
3627
 
3621
3628
  # @private
3622
3629
  def initialize parent_config = nil