google-cloud-kms-v1 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (32) hide show
  1. checksums.yaml +7 -0
  2. data/.yardopts +12 -0
  3. data/AUTHENTICATION.md +169 -0
  4. data/LICENSE.md +203 -0
  5. data/README.md +71 -0
  6. data/lib/google-cloud-kms-v1.rb +21 -0
  7. data/lib/google/cloud/kms/v1.rb +36 -0
  8. data/lib/google/cloud/kms/v1/iam_policy.rb +72 -0
  9. data/lib/google/cloud/kms/v1/iam_policy/client.rb +557 -0
  10. data/lib/google/cloud/kms/v1/iam_policy/credentials.rb +52 -0
  11. data/lib/google/cloud/kms/v1/key_management_service.rb +60 -0
  12. data/lib/google/cloud/kms/v1/key_management_service/client.rb +2393 -0
  13. data/lib/google/cloud/kms/v1/key_management_service/credentials.rb +52 -0
  14. data/lib/google/cloud/kms/v1/key_management_service/paths.rb +134 -0
  15. data/lib/google/cloud/kms/v1/resources_pb.rb +162 -0
  16. data/lib/google/cloud/kms/v1/service_pb.rb +210 -0
  17. data/lib/google/cloud/kms/v1/service_services_pb.rb +150 -0
  18. data/lib/google/cloud/kms/v1/version.rb +28 -0
  19. data/lib/google/iam/v1/iam_policy_services_pb.rb +81 -0
  20. data/proto_docs/README.md +4 -0
  21. data/proto_docs/google/api/field_behavior.rb +59 -0
  22. data/proto_docs/google/api/resource.rb +247 -0
  23. data/proto_docs/google/cloud/kms/v1/resources.rb +580 -0
  24. data/proto_docs/google/cloud/kms/v1/service.rb +594 -0
  25. data/proto_docs/google/iam/v1/iam_policy.rb +80 -0
  26. data/proto_docs/google/iam/v1/options.rb +40 -0
  27. data/proto_docs/google/iam/v1/policy.rb +248 -0
  28. data/proto_docs/google/protobuf/duration.rb +98 -0
  29. data/proto_docs/google/protobuf/field_mask.rb +229 -0
  30. data/proto_docs/google/protobuf/timestamp.rb +120 -0
  31. data/proto_docs/google/type/expr.rb +52 -0
  32. metadata +205 -0
@@ -0,0 +1,52 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright 2020 Google LLC
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # https://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+
17
+ # Auto-generated by gapic-generator-ruby. DO NOT EDIT!
18
+
19
+ require "googleauth"
20
+
21
+ module Google
22
+ module Cloud
23
+ module Kms
24
+ module V1
25
+ module IAMPolicy
26
+ # Credentials for the IAMPolicy API.
27
+ class Credentials < Google::Auth::Credentials
28
+ self.scope = [
29
+ "https://www.googleapis.com/auth/cloud-platform",
30
+ "https://www.googleapis.com/auth/cloudkms"
31
+ ]
32
+ self.env_vars = [
33
+ "KMS_CREDENTIALS",
34
+ "KMS_KEYFILE",
35
+ "GOOGLE_CLOUD_CREDENTIALS",
36
+ "GOOGLE_CLOUD_KEYFILE",
37
+ "GCLOUD_KEYFILE",
38
+ "KMS_CREDENTIALS_JSON",
39
+ "KMS_KEYFILE_JSON",
40
+ "GOOGLE_CLOUD_CREDENTIALS_JSON",
41
+ "GOOGLE_CLOUD_KEYFILE_JSON",
42
+ "GCLOUD_KEYFILE_JSON"
43
+ ]
44
+ self.paths = [
45
+ "~/.config/google_cloud/application_default_credentials.json"
46
+ ]
47
+ end
48
+ end
49
+ end
50
+ end
51
+ end
52
+ end
@@ -0,0 +1,60 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright 2020 Google LLC
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # https://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+
17
+ # Auto-generated by gapic-generator-ruby. DO NOT EDIT!
18
+
19
+ require "gapic/common"
20
+ require "gapic/config"
21
+ require "gapic/config/method"
22
+
23
+ require "google/cloud/kms/v1/version"
24
+
25
+ require "google/cloud/kms/v1/key_management_service/credentials"
26
+ require "google/cloud/kms/v1/key_management_service/paths"
27
+ require "google/cloud/kms/v1/key_management_service/client"
28
+
29
+ module Google
30
+ module Cloud
31
+ module Kms
32
+ module V1
33
+ ##
34
+ # Google Cloud Key Management Service
35
+ #
36
+ # Manages cryptographic keys and operations using those keys. Implements a REST
37
+ # model with the following objects:
38
+ #
39
+ # * {Google::Cloud::Kms::V1::KeyRing KeyRing}
40
+ # * {Google::Cloud::Kms::V1::CryptoKey CryptoKey}
41
+ # * {Google::Cloud::Kms::V1::CryptoKeyVersion CryptoKeyVersion}
42
+ # * {Google::Cloud::Kms::V1::ImportJob ImportJob}
43
+ #
44
+ # If you are using manual gRPC libraries, see
45
+ # [Using gRPC with Cloud KMS](https://cloud.google.com/kms/docs/grpc).
46
+ #
47
+ # To load this service and instantiate a client:
48
+ #
49
+ # require "google/cloud/kms/v1/key_management_service"
50
+ # client = Google::Cloud::Kms::V1::KeyManagementService::Client.new
51
+ #
52
+ module KeyManagementService
53
+ end
54
+ end
55
+ end
56
+ end
57
+ end
58
+
59
+ helper_path = ::File.join __dir__, "key_management_service", "helpers.rb"
60
+ require "google/cloud/kms/v1/key_management_service/helpers" if ::File.file? helper_path
@@ -0,0 +1,2393 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright 2020 Google LLC
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # https://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+
17
+ # Auto-generated by gapic-generator-ruby. DO NOT EDIT!
18
+
19
+ require "google/cloud/errors"
20
+ require "google/cloud/kms/v1/service_pb"
21
+
22
+ module Google
23
+ module Cloud
24
+ module Kms
25
+ module V1
26
+ module KeyManagementService
27
+ ##
28
+ # Client for the KeyManagementService service.
29
+ #
30
+ # Google Cloud Key Management Service
31
+ #
32
+ # Manages cryptographic keys and operations using those keys. Implements a REST
33
+ # model with the following objects:
34
+ #
35
+ # * {Google::Cloud::Kms::V1::KeyRing KeyRing}
36
+ # * {Google::Cloud::Kms::V1::CryptoKey CryptoKey}
37
+ # * {Google::Cloud::Kms::V1::CryptoKeyVersion CryptoKeyVersion}
38
+ # * {Google::Cloud::Kms::V1::ImportJob ImportJob}
39
+ #
40
+ # If you are using manual gRPC libraries, see
41
+ # [Using gRPC with Cloud KMS](https://cloud.google.com/kms/docs/grpc).
42
+ #
43
+ class Client
44
+ include Paths
45
+
46
+ # @private
47
+ attr_reader :key_management_service_stub
48
+
49
+ ##
50
+ # Configure the KeyManagementService Client class.
51
+ #
52
+ # See {Google::Cloud::Kms::V1::KeyManagementService::Client::Configuration}
53
+ # for a description of the configuration fields.
54
+ #
55
+ # ## Example
56
+ #
57
+ # To modify the configuration for all KeyManagementService clients:
58
+ #
59
+ # Google::Cloud::Kms::V1::KeyManagementService::Client.configure do |config|
60
+ # config.timeout = 10_000
61
+ # end
62
+ #
63
+ # @yield [config] Configure the Client client.
64
+ # @yieldparam config [Client::Configuration]
65
+ #
66
+ # @return [Client::Configuration]
67
+ #
68
+ def self.configure
69
+ @configure ||= begin
70
+ namespace = ["Google", "Cloud", "Kms", "V1"]
71
+ parent_config = while namespace.any?
72
+ parent_name = namespace.join "::"
73
+ parent_const = const_get parent_name
74
+ break parent_const.configure if parent_const&.respond_to? :configure
75
+ namespace.pop
76
+ end
77
+ default_config = Client::Configuration.new parent_config
78
+
79
+ default_config.rpcs.list_key_rings.timeout = 60.0
80
+ default_config.rpcs.list_key_rings.retry_policy = {
81
+ initial_delay: 0.1,
82
+ max_delay: 60.0,
83
+ multiplier: 1.3,
84
+ retry_codes: ["INTERNAL", "UNAVAILABLE", "DEADLINE_EXCEEDED"]
85
+ }
86
+
87
+ default_config.rpcs.list_crypto_keys.timeout = 60.0
88
+ default_config.rpcs.list_crypto_keys.retry_policy = {
89
+ initial_delay: 0.1,
90
+ max_delay: 60.0,
91
+ multiplier: 1.3,
92
+ retry_codes: ["INTERNAL", "UNAVAILABLE", "DEADLINE_EXCEEDED"]
93
+ }
94
+
95
+ default_config.rpcs.list_crypto_key_versions.timeout = 60.0
96
+ default_config.rpcs.list_crypto_key_versions.retry_policy = {
97
+ initial_delay: 0.1,
98
+ max_delay: 60.0,
99
+ multiplier: 1.3,
100
+ retry_codes: ["INTERNAL", "UNAVAILABLE", "DEADLINE_EXCEEDED"]
101
+ }
102
+
103
+ default_config.rpcs.list_import_jobs.timeout = 60.0
104
+ default_config.rpcs.list_import_jobs.retry_policy = {
105
+ initial_delay: 0.1,
106
+ max_delay: 60.0,
107
+ multiplier: 1.3,
108
+ retry_codes: ["INTERNAL", "UNAVAILABLE", "DEADLINE_EXCEEDED"]
109
+ }
110
+
111
+ default_config.rpcs.get_key_ring.timeout = 60.0
112
+ default_config.rpcs.get_key_ring.retry_policy = {
113
+ initial_delay: 0.1,
114
+ max_delay: 60.0,
115
+ multiplier: 1.3,
116
+ retry_codes: ["INTERNAL", "UNAVAILABLE", "DEADLINE_EXCEEDED"]
117
+ }
118
+
119
+ default_config.rpcs.get_crypto_key.timeout = 60.0
120
+ default_config.rpcs.get_crypto_key.retry_policy = {
121
+ initial_delay: 0.1,
122
+ max_delay: 60.0,
123
+ multiplier: 1.3,
124
+ retry_codes: ["INTERNAL", "UNAVAILABLE", "DEADLINE_EXCEEDED"]
125
+ }
126
+
127
+ default_config.rpcs.get_crypto_key_version.timeout = 60.0
128
+ default_config.rpcs.get_crypto_key_version.retry_policy = {
129
+ initial_delay: 0.1,
130
+ max_delay: 60.0,
131
+ multiplier: 1.3,
132
+ retry_codes: ["INTERNAL", "UNAVAILABLE", "DEADLINE_EXCEEDED"]
133
+ }
134
+
135
+ default_config.rpcs.get_public_key.timeout = 60.0
136
+ default_config.rpcs.get_public_key.retry_policy = {
137
+ initial_delay: 0.1,
138
+ max_delay: 60.0,
139
+ multiplier: 1.3,
140
+ retry_codes: ["INTERNAL", "UNAVAILABLE", "DEADLINE_EXCEEDED"]
141
+ }
142
+
143
+ default_config.rpcs.get_import_job.timeout = 60.0
144
+ default_config.rpcs.get_import_job.retry_policy = {
145
+ initial_delay: 0.1,
146
+ max_delay: 60.0,
147
+ multiplier: 1.3,
148
+ retry_codes: ["INTERNAL", "UNAVAILABLE", "DEADLINE_EXCEEDED"]
149
+ }
150
+
151
+ default_config.rpcs.create_key_ring.timeout = 60.0
152
+ default_config.rpcs.create_key_ring.retry_policy = {
153
+ initial_delay: 0.1,
154
+ max_delay: 60.0,
155
+ multiplier: 1.3,
156
+ retry_codes: ["INTERNAL", "UNAVAILABLE", "DEADLINE_EXCEEDED"]
157
+ }
158
+
159
+ default_config.rpcs.create_crypto_key.timeout = 60.0
160
+ default_config.rpcs.create_crypto_key.retry_policy = {
161
+ initial_delay: 0.1,
162
+ max_delay: 60.0,
163
+ multiplier: 1.3,
164
+ retry_codes: ["INTERNAL", "UNAVAILABLE", "DEADLINE_EXCEEDED"]
165
+ }
166
+
167
+ default_config.rpcs.create_crypto_key_version.timeout = 60.0
168
+
169
+ default_config.rpcs.import_crypto_key_version.timeout = 60.0
170
+
171
+ default_config.rpcs.create_import_job.timeout = 60.0
172
+ default_config.rpcs.create_import_job.retry_policy = {
173
+ initial_delay: 0.1,
174
+ max_delay: 60.0,
175
+ multiplier: 1.3,
176
+ retry_codes: ["INTERNAL", "UNAVAILABLE", "DEADLINE_EXCEEDED"]
177
+ }
178
+
179
+ default_config.rpcs.update_crypto_key.timeout = 60.0
180
+ default_config.rpcs.update_crypto_key.retry_policy = {
181
+ initial_delay: 0.1,
182
+ max_delay: 60.0,
183
+ multiplier: 1.3,
184
+ retry_codes: ["INTERNAL", "UNAVAILABLE", "DEADLINE_EXCEEDED"]
185
+ }
186
+
187
+ default_config.rpcs.update_crypto_key_version.timeout = 60.0
188
+ default_config.rpcs.update_crypto_key_version.retry_policy = {
189
+ initial_delay: 0.1,
190
+ max_delay: 60.0,
191
+ multiplier: 1.3,
192
+ retry_codes: ["INTERNAL", "UNAVAILABLE", "DEADLINE_EXCEEDED"]
193
+ }
194
+
195
+ default_config.rpcs.encrypt.timeout = 60.0
196
+ default_config.rpcs.encrypt.retry_policy = {
197
+ initial_delay: 0.1,
198
+ max_delay: 60.0,
199
+ multiplier: 1.3,
200
+ retry_codes: ["INTERNAL", "UNAVAILABLE", "DEADLINE_EXCEEDED"]
201
+ }
202
+
203
+ default_config.rpcs.decrypt.timeout = 60.0
204
+ default_config.rpcs.decrypt.retry_policy = {
205
+ initial_delay: 0.1,
206
+ max_delay: 60.0,
207
+ multiplier: 1.3,
208
+ retry_codes: ["INTERNAL", "UNAVAILABLE", "DEADLINE_EXCEEDED"]
209
+ }
210
+
211
+ default_config.rpcs.asymmetric_sign.timeout = 60.0
212
+ default_config.rpcs.asymmetric_sign.retry_policy = {
213
+ initial_delay: 0.1,
214
+ max_delay: 60.0,
215
+ multiplier: 1.3,
216
+ retry_codes: ["INTERNAL", "UNAVAILABLE", "DEADLINE_EXCEEDED"]
217
+ }
218
+
219
+ default_config.rpcs.asymmetric_decrypt.timeout = 60.0
220
+ default_config.rpcs.asymmetric_decrypt.retry_policy = {
221
+ initial_delay: 0.1,
222
+ max_delay: 60.0,
223
+ multiplier: 1.3,
224
+ retry_codes: ["INTERNAL", "UNAVAILABLE", "DEADLINE_EXCEEDED"]
225
+ }
226
+
227
+ default_config.rpcs.update_crypto_key_primary_version.timeout = 60.0
228
+ default_config.rpcs.update_crypto_key_primary_version.retry_policy = {
229
+ initial_delay: 0.1,
230
+ max_delay: 60.0,
231
+ multiplier: 1.3,
232
+ retry_codes: ["INTERNAL", "UNAVAILABLE", "DEADLINE_EXCEEDED"]
233
+ }
234
+
235
+ default_config.rpcs.destroy_crypto_key_version.timeout = 60.0
236
+ default_config.rpcs.destroy_crypto_key_version.retry_policy = {
237
+ initial_delay: 0.1,
238
+ max_delay: 60.0,
239
+ multiplier: 1.3,
240
+ retry_codes: ["INTERNAL", "UNAVAILABLE", "DEADLINE_EXCEEDED"]
241
+ }
242
+
243
+ default_config.rpcs.restore_crypto_key_version.timeout = 60.0
244
+ default_config.rpcs.restore_crypto_key_version.retry_policy = {
245
+ initial_delay: 0.1,
246
+ max_delay: 60.0,
247
+ multiplier: 1.3,
248
+ retry_codes: ["INTERNAL", "UNAVAILABLE", "DEADLINE_EXCEEDED"]
249
+ }
250
+
251
+ default_config
252
+ end
253
+ yield @configure if block_given?
254
+ @configure
255
+ end
256
+
257
+ ##
258
+ # Configure the KeyManagementService Client instance.
259
+ #
260
+ # The configuration is set to the derived mode, meaning that values can be changed,
261
+ # but structural changes (adding new fields, etc.) are not allowed. Structural changes
262
+ # should be made on {Client.configure}.
263
+ #
264
+ # See {Google::Cloud::Kms::V1::KeyManagementService::Client::Configuration}
265
+ # for a description of the configuration fields.
266
+ #
267
+ # @yield [config] Configure the Client client.
268
+ # @yieldparam config [Client::Configuration]
269
+ #
270
+ # @return [Client::Configuration]
271
+ #
272
+ def configure
273
+ yield @config if block_given?
274
+ @config
275
+ end
276
+
277
+ ##
278
+ # Create a new KeyManagementService client object.
279
+ #
280
+ # ## Examples
281
+ #
282
+ # To create a new KeyManagementService client with the default
283
+ # configuration:
284
+ #
285
+ # client = Google::Cloud::Kms::V1::KeyManagementService::Client.new
286
+ #
287
+ # To create a new KeyManagementService client with a custom
288
+ # configuration:
289
+ #
290
+ # client = Google::Cloud::Kms::V1::KeyManagementService::Client.new do |config|
291
+ # config.timeout = 10_000
292
+ # end
293
+ #
294
+ # @yield [config] Configure the KeyManagementService client.
295
+ # @yieldparam config [Client::Configuration]
296
+ #
297
+ def initialize
298
+ # These require statements are intentionally placed here to initialize
299
+ # the gRPC module only when it's required.
300
+ # See https://github.com/googleapis/toolkit/issues/446
301
+ require "gapic/grpc"
302
+ require "google/cloud/kms/v1/service_services_pb"
303
+
304
+ # Create the configuration object
305
+ @config = Configuration.new Client.configure
306
+
307
+ # Yield the configuration if needed
308
+ yield @config if block_given?
309
+
310
+ # Create credentials
311
+ credentials = @config.credentials
312
+ credentials ||= Credentials.default scope: @config.scope
313
+ if credentials.is_a?(String) || credentials.is_a?(Hash)
314
+ credentials = Credentials.new credentials, scope: @config.scope
315
+ end
316
+ @quota_project_id = credentials.respond_to?(:quota_project_id) ? credentials.quota_project_id : nil
317
+
318
+ @key_management_service_stub = Gapic::ServiceStub.new(
319
+ Google::Cloud::Kms::V1::KeyManagementService::Stub,
320
+ credentials: credentials,
321
+ endpoint: @config.endpoint,
322
+ channel_args: @config.channel_args,
323
+ interceptors: @config.interceptors
324
+ )
325
+ end
326
+
327
+ # Service calls
328
+
329
+ ##
330
+ # Lists {Google::Cloud::Kms::V1::KeyRing KeyRings}.
331
+ #
332
+ # @overload list_key_rings(request, options = nil)
333
+ # Pass arguments to `list_key_rings` via a request object, either of type
334
+ # {Google::Cloud::Kms::V1::ListKeyRingsRequest} or an equivalent Hash.
335
+ #
336
+ # @param request [Google::Cloud::Kms::V1::ListKeyRingsRequest, Hash]
337
+ # A request object representing the call parameters. Required. To specify no
338
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
339
+ # @param options [Gapic::CallOptions, Hash]
340
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
341
+ #
342
+ # @overload list_key_rings(parent: nil, page_size: nil, page_token: nil, filter: nil, order_by: nil)
343
+ # Pass arguments to `list_key_rings` via keyword arguments. Note that at
344
+ # least one keyword argument is required. To specify no parameters, or to keep all
345
+ # the default parameter values, pass an empty Hash as a request object (see above).
346
+ #
347
+ # @param parent [String]
348
+ # Required. The resource name of the location associated with the
349
+ # {Google::Cloud::Kms::V1::KeyRing KeyRings}, in the format `projects/*/locations/*`.
350
+ # @param page_size [Integer]
351
+ # Optional. Optional limit on the number of {Google::Cloud::Kms::V1::KeyRing KeyRings} to include in the
352
+ # response. Further {Google::Cloud::Kms::V1::KeyRing KeyRings} can subsequently be obtained by
353
+ # including the {Google::Cloud::Kms::V1::ListKeyRingsResponse#next_page_token ListKeyRingsResponse.next_page_token} in a subsequent
354
+ # request. If unspecified, the server will pick an appropriate default.
355
+ # @param page_token [String]
356
+ # Optional. Optional pagination token, returned earlier via
357
+ # {Google::Cloud::Kms::V1::ListKeyRingsResponse#next_page_token ListKeyRingsResponse.next_page_token}.
358
+ # @param filter [String]
359
+ # Optional. Only include resources that match the filter in the response. For
360
+ # more information, see
361
+ # [Sorting and filtering list
362
+ # results](https://cloud.google.com/kms/docs/sorting-and-filtering).
363
+ # @param order_by [String]
364
+ # Optional. Specify how the results should be sorted. If not specified, the
365
+ # results will be sorted in the default order. For more information, see
366
+ # [Sorting and filtering list
367
+ # results](https://cloud.google.com/kms/docs/sorting-and-filtering).
368
+ #
369
+ # @yield [response, operation] Access the result along with the RPC operation
370
+ # @yieldparam response [Gapic::PagedEnumerable<Google::Cloud::Kms::V1::KeyRing>]
371
+ # @yieldparam operation [GRPC::ActiveCall::Operation]
372
+ #
373
+ # @return [Gapic::PagedEnumerable<Google::Cloud::Kms::V1::KeyRing>]
374
+ #
375
+ # @raise [Google::Cloud::Error] if the RPC is aborted.
376
+ #
377
+ def list_key_rings request, options = nil
378
+ raise ArgumentError, "request must be provided" if request.nil?
379
+
380
+ request = Gapic::Protobuf.coerce request, to: Google::Cloud::Kms::V1::ListKeyRingsRequest
381
+
382
+ # Converts hash and nil to an options object
383
+ options = Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
384
+
385
+ # Customize the options with defaults
386
+ metadata = @config.rpcs.list_key_rings.metadata.to_h
387
+
388
+ # Set x-goog-api-client and x-goog-user-project headers
389
+ metadata[:"x-goog-api-client"] ||= Gapic::Headers.x_goog_api_client \
390
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
391
+ gapic_version: ::Google::Cloud::Kms::V1::VERSION
392
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
393
+
394
+ header_params = {
395
+ "parent" => request.parent
396
+ }
397
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
398
+ metadata[:"x-goog-request-params"] ||= request_params_header
399
+
400
+ options.apply_defaults timeout: @config.rpcs.list_key_rings.timeout,
401
+ metadata: metadata,
402
+ retry_policy: @config.rpcs.list_key_rings.retry_policy
403
+ options.apply_defaults metadata: @config.metadata,
404
+ retry_policy: @config.retry_policy
405
+
406
+ @key_management_service_stub.call_rpc :list_key_rings, request, options: options do |response, operation|
407
+ response = Gapic::PagedEnumerable.new @key_management_service_stub, :list_key_rings, request, response, operation, options
408
+ yield response, operation if block_given?
409
+ return response
410
+ end
411
+ rescue GRPC::BadStatus => e
412
+ raise Google::Cloud::Error.from_error(e)
413
+ end
414
+
415
+ ##
416
+ # Lists {Google::Cloud::Kms::V1::CryptoKey CryptoKeys}.
417
+ #
418
+ # @overload list_crypto_keys(request, options = nil)
419
+ # Pass arguments to `list_crypto_keys` via a request object, either of type
420
+ # {Google::Cloud::Kms::V1::ListCryptoKeysRequest} or an equivalent Hash.
421
+ #
422
+ # @param request [Google::Cloud::Kms::V1::ListCryptoKeysRequest, Hash]
423
+ # A request object representing the call parameters. Required. To specify no
424
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
425
+ # @param options [Gapic::CallOptions, Hash]
426
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
427
+ #
428
+ # @overload list_crypto_keys(parent: nil, page_size: nil, page_token: nil, version_view: nil, filter: nil, order_by: nil)
429
+ # Pass arguments to `list_crypto_keys` via keyword arguments. Note that at
430
+ # least one keyword argument is required. To specify no parameters, or to keep all
431
+ # the default parameter values, pass an empty Hash as a request object (see above).
432
+ #
433
+ # @param parent [String]
434
+ # Required. The resource name of the {Google::Cloud::Kms::V1::KeyRing KeyRing} to list, in the format
435
+ # `projects/*/locations/*/keyRings/*`.
436
+ # @param page_size [Integer]
437
+ # Optional. Optional limit on the number of {Google::Cloud::Kms::V1::CryptoKey CryptoKeys} to include in the
438
+ # response. Further {Google::Cloud::Kms::V1::CryptoKey CryptoKeys} can subsequently be obtained by
439
+ # including the {Google::Cloud::Kms::V1::ListCryptoKeysResponse#next_page_token ListCryptoKeysResponse.next_page_token} in a subsequent
440
+ # request. If unspecified, the server will pick an appropriate default.
441
+ # @param page_token [String]
442
+ # Optional. Optional pagination token, returned earlier via
443
+ # {Google::Cloud::Kms::V1::ListCryptoKeysResponse#next_page_token ListCryptoKeysResponse.next_page_token}.
444
+ # @param version_view [Google::Cloud::Kms::V1::CryptoKeyVersion::CryptoKeyVersionView]
445
+ # The fields of the primary version to include in the response.
446
+ # @param filter [String]
447
+ # Optional. Only include resources that match the filter in the response. For
448
+ # more information, see
449
+ # [Sorting and filtering list
450
+ # results](https://cloud.google.com/kms/docs/sorting-and-filtering).
451
+ # @param order_by [String]
452
+ # Optional. Specify how the results should be sorted. If not specified, the
453
+ # results will be sorted in the default order. For more information, see
454
+ # [Sorting and filtering list
455
+ # results](https://cloud.google.com/kms/docs/sorting-and-filtering).
456
+ #
457
+ # @yield [response, operation] Access the result along with the RPC operation
458
+ # @yieldparam response [Gapic::PagedEnumerable<Google::Cloud::Kms::V1::CryptoKey>]
459
+ # @yieldparam operation [GRPC::ActiveCall::Operation]
460
+ #
461
+ # @return [Gapic::PagedEnumerable<Google::Cloud::Kms::V1::CryptoKey>]
462
+ #
463
+ # @raise [Google::Cloud::Error] if the RPC is aborted.
464
+ #
465
+ def list_crypto_keys request, options = nil
466
+ raise ArgumentError, "request must be provided" if request.nil?
467
+
468
+ request = Gapic::Protobuf.coerce request, to: Google::Cloud::Kms::V1::ListCryptoKeysRequest
469
+
470
+ # Converts hash and nil to an options object
471
+ options = Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
472
+
473
+ # Customize the options with defaults
474
+ metadata = @config.rpcs.list_crypto_keys.metadata.to_h
475
+
476
+ # Set x-goog-api-client and x-goog-user-project headers
477
+ metadata[:"x-goog-api-client"] ||= Gapic::Headers.x_goog_api_client \
478
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
479
+ gapic_version: ::Google::Cloud::Kms::V1::VERSION
480
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
481
+
482
+ header_params = {
483
+ "parent" => request.parent
484
+ }
485
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
486
+ metadata[:"x-goog-request-params"] ||= request_params_header
487
+
488
+ options.apply_defaults timeout: @config.rpcs.list_crypto_keys.timeout,
489
+ metadata: metadata,
490
+ retry_policy: @config.rpcs.list_crypto_keys.retry_policy
491
+ options.apply_defaults metadata: @config.metadata,
492
+ retry_policy: @config.retry_policy
493
+
494
+ @key_management_service_stub.call_rpc :list_crypto_keys, request, options: options do |response, operation|
495
+ response = Gapic::PagedEnumerable.new @key_management_service_stub, :list_crypto_keys, request, response, operation, options
496
+ yield response, operation if block_given?
497
+ return response
498
+ end
499
+ rescue GRPC::BadStatus => e
500
+ raise Google::Cloud::Error.from_error(e)
501
+ end
502
+
503
+ ##
504
+ # Lists {Google::Cloud::Kms::V1::CryptoKeyVersion CryptoKeyVersions}.
505
+ #
506
+ # @overload list_crypto_key_versions(request, options = nil)
507
+ # Pass arguments to `list_crypto_key_versions` via a request object, either of type
508
+ # {Google::Cloud::Kms::V1::ListCryptoKeyVersionsRequest} or an equivalent Hash.
509
+ #
510
+ # @param request [Google::Cloud::Kms::V1::ListCryptoKeyVersionsRequest, Hash]
511
+ # A request object representing the call parameters. Required. To specify no
512
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
513
+ # @param options [Gapic::CallOptions, Hash]
514
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
515
+ #
516
+ # @overload list_crypto_key_versions(parent: nil, page_size: nil, page_token: nil, view: nil, filter: nil, order_by: nil)
517
+ # Pass arguments to `list_crypto_key_versions` via keyword arguments. Note that at
518
+ # least one keyword argument is required. To specify no parameters, or to keep all
519
+ # the default parameter values, pass an empty Hash as a request object (see above).
520
+ #
521
+ # @param parent [String]
522
+ # Required. The resource name of the {Google::Cloud::Kms::V1::CryptoKey CryptoKey} to list, in the format
523
+ # `projects/*/locations/*/keyRings/*/cryptoKeys/*`.
524
+ # @param page_size [Integer]
525
+ # Optional. Optional limit on the number of {Google::Cloud::Kms::V1::CryptoKeyVersion CryptoKeyVersions} to
526
+ # include in the response. Further {Google::Cloud::Kms::V1::CryptoKeyVersion CryptoKeyVersions} can
527
+ # subsequently be obtained by including the
528
+ # {Google::Cloud::Kms::V1::ListCryptoKeyVersionsResponse#next_page_token ListCryptoKeyVersionsResponse.next_page_token} in a subsequent request.
529
+ # If unspecified, the server will pick an appropriate default.
530
+ # @param page_token [String]
531
+ # Optional. Optional pagination token, returned earlier via
532
+ # {Google::Cloud::Kms::V1::ListCryptoKeyVersionsResponse#next_page_token ListCryptoKeyVersionsResponse.next_page_token}.
533
+ # @param view [Google::Cloud::Kms::V1::CryptoKeyVersion::CryptoKeyVersionView]
534
+ # The fields to include in the response.
535
+ # @param filter [String]
536
+ # Optional. Only include resources that match the filter in the response. For
537
+ # more information, see
538
+ # [Sorting and filtering list
539
+ # results](https://cloud.google.com/kms/docs/sorting-and-filtering).
540
+ # @param order_by [String]
541
+ # Optional. Specify how the results should be sorted. If not specified, the
542
+ # results will be sorted in the default order. For more information, see
543
+ # [Sorting and filtering list
544
+ # results](https://cloud.google.com/kms/docs/sorting-and-filtering).
545
+ #
546
+ # @yield [response, operation] Access the result along with the RPC operation
547
+ # @yieldparam response [Gapic::PagedEnumerable<Google::Cloud::Kms::V1::CryptoKeyVersion>]
548
+ # @yieldparam operation [GRPC::ActiveCall::Operation]
549
+ #
550
+ # @return [Gapic::PagedEnumerable<Google::Cloud::Kms::V1::CryptoKeyVersion>]
551
+ #
552
+ # @raise [Google::Cloud::Error] if the RPC is aborted.
553
+ #
554
+ def list_crypto_key_versions request, options = nil
555
+ raise ArgumentError, "request must be provided" if request.nil?
556
+
557
+ request = Gapic::Protobuf.coerce request, to: Google::Cloud::Kms::V1::ListCryptoKeyVersionsRequest
558
+
559
+ # Converts hash and nil to an options object
560
+ options = Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
561
+
562
+ # Customize the options with defaults
563
+ metadata = @config.rpcs.list_crypto_key_versions.metadata.to_h
564
+
565
+ # Set x-goog-api-client and x-goog-user-project headers
566
+ metadata[:"x-goog-api-client"] ||= Gapic::Headers.x_goog_api_client \
567
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
568
+ gapic_version: ::Google::Cloud::Kms::V1::VERSION
569
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
570
+
571
+ header_params = {
572
+ "parent" => request.parent
573
+ }
574
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
575
+ metadata[:"x-goog-request-params"] ||= request_params_header
576
+
577
+ options.apply_defaults timeout: @config.rpcs.list_crypto_key_versions.timeout,
578
+ metadata: metadata,
579
+ retry_policy: @config.rpcs.list_crypto_key_versions.retry_policy
580
+ options.apply_defaults metadata: @config.metadata,
581
+ retry_policy: @config.retry_policy
582
+
583
+ @key_management_service_stub.call_rpc :list_crypto_key_versions, request, options: options do |response, operation|
584
+ response = Gapic::PagedEnumerable.new @key_management_service_stub, :list_crypto_key_versions, request, response, operation, options
585
+ yield response, operation if block_given?
586
+ return response
587
+ end
588
+ rescue GRPC::BadStatus => e
589
+ raise Google::Cloud::Error.from_error(e)
590
+ end
591
+
592
+ ##
593
+ # Lists {Google::Cloud::Kms::V1::ImportJob ImportJobs}.
594
+ #
595
+ # @overload list_import_jobs(request, options = nil)
596
+ # Pass arguments to `list_import_jobs` via a request object, either of type
597
+ # {Google::Cloud::Kms::V1::ListImportJobsRequest} or an equivalent Hash.
598
+ #
599
+ # @param request [Google::Cloud::Kms::V1::ListImportJobsRequest, Hash]
600
+ # A request object representing the call parameters. Required. To specify no
601
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
602
+ # @param options [Gapic::CallOptions, Hash]
603
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
604
+ #
605
+ # @overload list_import_jobs(parent: nil, page_size: nil, page_token: nil, filter: nil, order_by: nil)
606
+ # Pass arguments to `list_import_jobs` via keyword arguments. Note that at
607
+ # least one keyword argument is required. To specify no parameters, or to keep all
608
+ # the default parameter values, pass an empty Hash as a request object (see above).
609
+ #
610
+ # @param parent [String]
611
+ # Required. The resource name of the {Google::Cloud::Kms::V1::KeyRing KeyRing} to list, in the format
612
+ # `projects/*/locations/*/keyRings/*`.
613
+ # @param page_size [Integer]
614
+ # Optional. Optional limit on the number of {Google::Cloud::Kms::V1::ImportJob ImportJobs} to include in the
615
+ # response. Further {Google::Cloud::Kms::V1::ImportJob ImportJobs} can subsequently be obtained by
616
+ # including the {Google::Cloud::Kms::V1::ListImportJobsResponse#next_page_token ListImportJobsResponse.next_page_token} in a subsequent
617
+ # request. If unspecified, the server will pick an appropriate default.
618
+ # @param page_token [String]
619
+ # Optional. Optional pagination token, returned earlier via
620
+ # {Google::Cloud::Kms::V1::ListImportJobsResponse#next_page_token ListImportJobsResponse.next_page_token}.
621
+ # @param filter [String]
622
+ # Optional. Only include resources that match the filter in the response. For
623
+ # more information, see
624
+ # [Sorting and filtering list
625
+ # results](https://cloud.google.com/kms/docs/sorting-and-filtering).
626
+ # @param order_by [String]
627
+ # Optional. Specify how the results should be sorted. If not specified, the
628
+ # results will be sorted in the default order. For more information, see
629
+ # [Sorting and filtering list
630
+ # results](https://cloud.google.com/kms/docs/sorting-and-filtering).
631
+ #
632
+ # @yield [response, operation] Access the result along with the RPC operation
633
+ # @yieldparam response [Gapic::PagedEnumerable<Google::Cloud::Kms::V1::ImportJob>]
634
+ # @yieldparam operation [GRPC::ActiveCall::Operation]
635
+ #
636
+ # @return [Gapic::PagedEnumerable<Google::Cloud::Kms::V1::ImportJob>]
637
+ #
638
+ # @raise [Google::Cloud::Error] if the RPC is aborted.
639
+ #
640
+ def list_import_jobs request, options = nil
641
+ raise ArgumentError, "request must be provided" if request.nil?
642
+
643
+ request = Gapic::Protobuf.coerce request, to: Google::Cloud::Kms::V1::ListImportJobsRequest
644
+
645
+ # Converts hash and nil to an options object
646
+ options = Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
647
+
648
+ # Customize the options with defaults
649
+ metadata = @config.rpcs.list_import_jobs.metadata.to_h
650
+
651
+ # Set x-goog-api-client and x-goog-user-project headers
652
+ metadata[:"x-goog-api-client"] ||= Gapic::Headers.x_goog_api_client \
653
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
654
+ gapic_version: ::Google::Cloud::Kms::V1::VERSION
655
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
656
+
657
+ header_params = {
658
+ "parent" => request.parent
659
+ }
660
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
661
+ metadata[:"x-goog-request-params"] ||= request_params_header
662
+
663
+ options.apply_defaults timeout: @config.rpcs.list_import_jobs.timeout,
664
+ metadata: metadata,
665
+ retry_policy: @config.rpcs.list_import_jobs.retry_policy
666
+ options.apply_defaults metadata: @config.metadata,
667
+ retry_policy: @config.retry_policy
668
+
669
+ @key_management_service_stub.call_rpc :list_import_jobs, request, options: options do |response, operation|
670
+ response = Gapic::PagedEnumerable.new @key_management_service_stub, :list_import_jobs, request, response, operation, options
671
+ yield response, operation if block_given?
672
+ return response
673
+ end
674
+ rescue GRPC::BadStatus => e
675
+ raise Google::Cloud::Error.from_error(e)
676
+ end
677
+
678
+ ##
679
+ # Returns metadata for a given {Google::Cloud::Kms::V1::KeyRing KeyRing}.
680
+ #
681
+ # @overload get_key_ring(request, options = nil)
682
+ # Pass arguments to `get_key_ring` via a request object, either of type
683
+ # {Google::Cloud::Kms::V1::GetKeyRingRequest} or an equivalent Hash.
684
+ #
685
+ # @param request [Google::Cloud::Kms::V1::GetKeyRingRequest, Hash]
686
+ # A request object representing the call parameters. Required. To specify no
687
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
688
+ # @param options [Gapic::CallOptions, Hash]
689
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
690
+ #
691
+ # @overload get_key_ring(name: nil)
692
+ # Pass arguments to `get_key_ring` via keyword arguments. Note that at
693
+ # least one keyword argument is required. To specify no parameters, or to keep all
694
+ # the default parameter values, pass an empty Hash as a request object (see above).
695
+ #
696
+ # @param name [String]
697
+ # Required. The {Google::Cloud::Kms::V1::KeyRing#name name} of the {Google::Cloud::Kms::V1::KeyRing KeyRing} to get.
698
+ #
699
+ # @yield [response, operation] Access the result along with the RPC operation
700
+ # @yieldparam response [Google::Cloud::Kms::V1::KeyRing]
701
+ # @yieldparam operation [GRPC::ActiveCall::Operation]
702
+ #
703
+ # @return [Google::Cloud::Kms::V1::KeyRing]
704
+ #
705
+ # @raise [Google::Cloud::Error] if the RPC is aborted.
706
+ #
707
+ def get_key_ring request, options = nil
708
+ raise ArgumentError, "request must be provided" if request.nil?
709
+
710
+ request = Gapic::Protobuf.coerce request, to: Google::Cloud::Kms::V1::GetKeyRingRequest
711
+
712
+ # Converts hash and nil to an options object
713
+ options = Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
714
+
715
+ # Customize the options with defaults
716
+ metadata = @config.rpcs.get_key_ring.metadata.to_h
717
+
718
+ # Set x-goog-api-client and x-goog-user-project headers
719
+ metadata[:"x-goog-api-client"] ||= Gapic::Headers.x_goog_api_client \
720
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
721
+ gapic_version: ::Google::Cloud::Kms::V1::VERSION
722
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
723
+
724
+ header_params = {
725
+ "name" => request.name
726
+ }
727
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
728
+ metadata[:"x-goog-request-params"] ||= request_params_header
729
+
730
+ options.apply_defaults timeout: @config.rpcs.get_key_ring.timeout,
731
+ metadata: metadata,
732
+ retry_policy: @config.rpcs.get_key_ring.retry_policy
733
+ options.apply_defaults metadata: @config.metadata,
734
+ retry_policy: @config.retry_policy
735
+
736
+ @key_management_service_stub.call_rpc :get_key_ring, request, options: options do |response, operation|
737
+ yield response, operation if block_given?
738
+ return response
739
+ end
740
+ rescue GRPC::BadStatus => e
741
+ raise Google::Cloud::Error.from_error(e)
742
+ end
743
+
744
+ ##
745
+ # Returns metadata for a given {Google::Cloud::Kms::V1::CryptoKey CryptoKey}, as well as its
746
+ # {Google::Cloud::Kms::V1::CryptoKey#primary primary} {Google::Cloud::Kms::V1::CryptoKeyVersion CryptoKeyVersion}.
747
+ #
748
+ # @overload get_crypto_key(request, options = nil)
749
+ # Pass arguments to `get_crypto_key` via a request object, either of type
750
+ # {Google::Cloud::Kms::V1::GetCryptoKeyRequest} or an equivalent Hash.
751
+ #
752
+ # @param request [Google::Cloud::Kms::V1::GetCryptoKeyRequest, Hash]
753
+ # A request object representing the call parameters. Required. To specify no
754
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
755
+ # @param options [Gapic::CallOptions, Hash]
756
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
757
+ #
758
+ # @overload get_crypto_key(name: nil)
759
+ # Pass arguments to `get_crypto_key` via keyword arguments. Note that at
760
+ # least one keyword argument is required. To specify no parameters, or to keep all
761
+ # the default parameter values, pass an empty Hash as a request object (see above).
762
+ #
763
+ # @param name [String]
764
+ # Required. The {Google::Cloud::Kms::V1::CryptoKey#name name} of the {Google::Cloud::Kms::V1::CryptoKey CryptoKey} to get.
765
+ #
766
+ # @yield [response, operation] Access the result along with the RPC operation
767
+ # @yieldparam response [Google::Cloud::Kms::V1::CryptoKey]
768
+ # @yieldparam operation [GRPC::ActiveCall::Operation]
769
+ #
770
+ # @return [Google::Cloud::Kms::V1::CryptoKey]
771
+ #
772
+ # @raise [Google::Cloud::Error] if the RPC is aborted.
773
+ #
774
+ def get_crypto_key request, options = nil
775
+ raise ArgumentError, "request must be provided" if request.nil?
776
+
777
+ request = Gapic::Protobuf.coerce request, to: Google::Cloud::Kms::V1::GetCryptoKeyRequest
778
+
779
+ # Converts hash and nil to an options object
780
+ options = Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
781
+
782
+ # Customize the options with defaults
783
+ metadata = @config.rpcs.get_crypto_key.metadata.to_h
784
+
785
+ # Set x-goog-api-client and x-goog-user-project headers
786
+ metadata[:"x-goog-api-client"] ||= Gapic::Headers.x_goog_api_client \
787
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
788
+ gapic_version: ::Google::Cloud::Kms::V1::VERSION
789
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
790
+
791
+ header_params = {
792
+ "name" => request.name
793
+ }
794
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
795
+ metadata[:"x-goog-request-params"] ||= request_params_header
796
+
797
+ options.apply_defaults timeout: @config.rpcs.get_crypto_key.timeout,
798
+ metadata: metadata,
799
+ retry_policy: @config.rpcs.get_crypto_key.retry_policy
800
+ options.apply_defaults metadata: @config.metadata,
801
+ retry_policy: @config.retry_policy
802
+
803
+ @key_management_service_stub.call_rpc :get_crypto_key, request, options: options do |response, operation|
804
+ yield response, operation if block_given?
805
+ return response
806
+ end
807
+ rescue GRPC::BadStatus => e
808
+ raise Google::Cloud::Error.from_error(e)
809
+ end
810
+
811
+ ##
812
+ # Returns metadata for a given {Google::Cloud::Kms::V1::CryptoKeyVersion CryptoKeyVersion}.
813
+ #
814
+ # @overload get_crypto_key_version(request, options = nil)
815
+ # Pass arguments to `get_crypto_key_version` via a request object, either of type
816
+ # {Google::Cloud::Kms::V1::GetCryptoKeyVersionRequest} or an equivalent Hash.
817
+ #
818
+ # @param request [Google::Cloud::Kms::V1::GetCryptoKeyVersionRequest, Hash]
819
+ # A request object representing the call parameters. Required. To specify no
820
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
821
+ # @param options [Gapic::CallOptions, Hash]
822
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
823
+ #
824
+ # @overload get_crypto_key_version(name: nil)
825
+ # Pass arguments to `get_crypto_key_version` via keyword arguments. Note that at
826
+ # least one keyword argument is required. To specify no parameters, or to keep all
827
+ # the default parameter values, pass an empty Hash as a request object (see above).
828
+ #
829
+ # @param name [String]
830
+ # Required. The {Google::Cloud::Kms::V1::CryptoKeyVersion#name name} of the {Google::Cloud::Kms::V1::CryptoKeyVersion CryptoKeyVersion} to get.
831
+ #
832
+ # @yield [response, operation] Access the result along with the RPC operation
833
+ # @yieldparam response [Google::Cloud::Kms::V1::CryptoKeyVersion]
834
+ # @yieldparam operation [GRPC::ActiveCall::Operation]
835
+ #
836
+ # @return [Google::Cloud::Kms::V1::CryptoKeyVersion]
837
+ #
838
+ # @raise [Google::Cloud::Error] if the RPC is aborted.
839
+ #
840
+ def get_crypto_key_version request, options = nil
841
+ raise ArgumentError, "request must be provided" if request.nil?
842
+
843
+ request = Gapic::Protobuf.coerce request, to: Google::Cloud::Kms::V1::GetCryptoKeyVersionRequest
844
+
845
+ # Converts hash and nil to an options object
846
+ options = Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
847
+
848
+ # Customize the options with defaults
849
+ metadata = @config.rpcs.get_crypto_key_version.metadata.to_h
850
+
851
+ # Set x-goog-api-client and x-goog-user-project headers
852
+ metadata[:"x-goog-api-client"] ||= Gapic::Headers.x_goog_api_client \
853
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
854
+ gapic_version: ::Google::Cloud::Kms::V1::VERSION
855
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
856
+
857
+ header_params = {
858
+ "name" => request.name
859
+ }
860
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
861
+ metadata[:"x-goog-request-params"] ||= request_params_header
862
+
863
+ options.apply_defaults timeout: @config.rpcs.get_crypto_key_version.timeout,
864
+ metadata: metadata,
865
+ retry_policy: @config.rpcs.get_crypto_key_version.retry_policy
866
+ options.apply_defaults metadata: @config.metadata,
867
+ retry_policy: @config.retry_policy
868
+
869
+ @key_management_service_stub.call_rpc :get_crypto_key_version, request, options: options do |response, operation|
870
+ yield response, operation if block_given?
871
+ return response
872
+ end
873
+ rescue GRPC::BadStatus => e
874
+ raise Google::Cloud::Error.from_error(e)
875
+ end
876
+
877
+ ##
878
+ # Returns the public key for the given {Google::Cloud::Kms::V1::CryptoKeyVersion CryptoKeyVersion}. The
879
+ # {Google::Cloud::Kms::V1::CryptoKey#purpose CryptoKey.purpose} must be
880
+ # {Google::Cloud::Kms::V1::CryptoKey::CryptoKeyPurpose::ASYMMETRIC_SIGN ASYMMETRIC_SIGN} or
881
+ # {Google::Cloud::Kms::V1::CryptoKey::CryptoKeyPurpose::ASYMMETRIC_DECRYPT ASYMMETRIC_DECRYPT}.
882
+ #
883
+ # @overload get_public_key(request, options = nil)
884
+ # Pass arguments to `get_public_key` via a request object, either of type
885
+ # {Google::Cloud::Kms::V1::GetPublicKeyRequest} or an equivalent Hash.
886
+ #
887
+ # @param request [Google::Cloud::Kms::V1::GetPublicKeyRequest, Hash]
888
+ # A request object representing the call parameters. Required. To specify no
889
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
890
+ # @param options [Gapic::CallOptions, Hash]
891
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
892
+ #
893
+ # @overload get_public_key(name: nil)
894
+ # Pass arguments to `get_public_key` via keyword arguments. Note that at
895
+ # least one keyword argument is required. To specify no parameters, or to keep all
896
+ # the default parameter values, pass an empty Hash as a request object (see above).
897
+ #
898
+ # @param name [String]
899
+ # Required. The {Google::Cloud::Kms::V1::CryptoKeyVersion#name name} of the {Google::Cloud::Kms::V1::CryptoKeyVersion CryptoKeyVersion} public key to
900
+ # get.
901
+ #
902
+ # @yield [response, operation] Access the result along with the RPC operation
903
+ # @yieldparam response [Google::Cloud::Kms::V1::PublicKey]
904
+ # @yieldparam operation [GRPC::ActiveCall::Operation]
905
+ #
906
+ # @return [Google::Cloud::Kms::V1::PublicKey]
907
+ #
908
+ # @raise [Google::Cloud::Error] if the RPC is aborted.
909
+ #
910
+ def get_public_key request, options = nil
911
+ raise ArgumentError, "request must be provided" if request.nil?
912
+
913
+ request = Gapic::Protobuf.coerce request, to: Google::Cloud::Kms::V1::GetPublicKeyRequest
914
+
915
+ # Converts hash and nil to an options object
916
+ options = Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
917
+
918
+ # Customize the options with defaults
919
+ metadata = @config.rpcs.get_public_key.metadata.to_h
920
+
921
+ # Set x-goog-api-client and x-goog-user-project headers
922
+ metadata[:"x-goog-api-client"] ||= Gapic::Headers.x_goog_api_client \
923
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
924
+ gapic_version: ::Google::Cloud::Kms::V1::VERSION
925
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
926
+
927
+ header_params = {
928
+ "name" => request.name
929
+ }
930
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
931
+ metadata[:"x-goog-request-params"] ||= request_params_header
932
+
933
+ options.apply_defaults timeout: @config.rpcs.get_public_key.timeout,
934
+ metadata: metadata,
935
+ retry_policy: @config.rpcs.get_public_key.retry_policy
936
+ options.apply_defaults metadata: @config.metadata,
937
+ retry_policy: @config.retry_policy
938
+
939
+ @key_management_service_stub.call_rpc :get_public_key, request, options: options do |response, operation|
940
+ yield response, operation if block_given?
941
+ return response
942
+ end
943
+ rescue GRPC::BadStatus => e
944
+ raise Google::Cloud::Error.from_error(e)
945
+ end
946
+
947
+ ##
948
+ # Returns metadata for a given {Google::Cloud::Kms::V1::ImportJob ImportJob}.
949
+ #
950
+ # @overload get_import_job(request, options = nil)
951
+ # Pass arguments to `get_import_job` via a request object, either of type
952
+ # {Google::Cloud::Kms::V1::GetImportJobRequest} or an equivalent Hash.
953
+ #
954
+ # @param request [Google::Cloud::Kms::V1::GetImportJobRequest, Hash]
955
+ # A request object representing the call parameters. Required. To specify no
956
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
957
+ # @param options [Gapic::CallOptions, Hash]
958
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
959
+ #
960
+ # @overload get_import_job(name: nil)
961
+ # Pass arguments to `get_import_job` via keyword arguments. Note that at
962
+ # least one keyword argument is required. To specify no parameters, or to keep all
963
+ # the default parameter values, pass an empty Hash as a request object (see above).
964
+ #
965
+ # @param name [String]
966
+ # Required. The {Google::Cloud::Kms::V1::ImportJob#name name} of the {Google::Cloud::Kms::V1::ImportJob ImportJob} to get.
967
+ #
968
+ # @yield [response, operation] Access the result along with the RPC operation
969
+ # @yieldparam response [Google::Cloud::Kms::V1::ImportJob]
970
+ # @yieldparam operation [GRPC::ActiveCall::Operation]
971
+ #
972
+ # @return [Google::Cloud::Kms::V1::ImportJob]
973
+ #
974
+ # @raise [Google::Cloud::Error] if the RPC is aborted.
975
+ #
976
+ def get_import_job request, options = nil
977
+ raise ArgumentError, "request must be provided" if request.nil?
978
+
979
+ request = Gapic::Protobuf.coerce request, to: Google::Cloud::Kms::V1::GetImportJobRequest
980
+
981
+ # Converts hash and nil to an options object
982
+ options = Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
983
+
984
+ # Customize the options with defaults
985
+ metadata = @config.rpcs.get_import_job.metadata.to_h
986
+
987
+ # Set x-goog-api-client and x-goog-user-project headers
988
+ metadata[:"x-goog-api-client"] ||= Gapic::Headers.x_goog_api_client \
989
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
990
+ gapic_version: ::Google::Cloud::Kms::V1::VERSION
991
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
992
+
993
+ header_params = {
994
+ "name" => request.name
995
+ }
996
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
997
+ metadata[:"x-goog-request-params"] ||= request_params_header
998
+
999
+ options.apply_defaults timeout: @config.rpcs.get_import_job.timeout,
1000
+ metadata: metadata,
1001
+ retry_policy: @config.rpcs.get_import_job.retry_policy
1002
+ options.apply_defaults metadata: @config.metadata,
1003
+ retry_policy: @config.retry_policy
1004
+
1005
+ @key_management_service_stub.call_rpc :get_import_job, request, options: options do |response, operation|
1006
+ yield response, operation if block_given?
1007
+ return response
1008
+ end
1009
+ rescue GRPC::BadStatus => e
1010
+ raise Google::Cloud::Error.from_error(e)
1011
+ end
1012
+
1013
+ ##
1014
+ # Create a new {Google::Cloud::Kms::V1::KeyRing KeyRing} in a given Project and Location.
1015
+ #
1016
+ # @overload create_key_ring(request, options = nil)
1017
+ # Pass arguments to `create_key_ring` via a request object, either of type
1018
+ # {Google::Cloud::Kms::V1::CreateKeyRingRequest} or an equivalent Hash.
1019
+ #
1020
+ # @param request [Google::Cloud::Kms::V1::CreateKeyRingRequest, Hash]
1021
+ # A request object representing the call parameters. Required. To specify no
1022
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
1023
+ # @param options [Gapic::CallOptions, Hash]
1024
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
1025
+ #
1026
+ # @overload create_key_ring(parent: nil, key_ring_id: nil, key_ring: nil)
1027
+ # Pass arguments to `create_key_ring` via keyword arguments. Note that at
1028
+ # least one keyword argument is required. To specify no parameters, or to keep all
1029
+ # the default parameter values, pass an empty Hash as a request object (see above).
1030
+ #
1031
+ # @param parent [String]
1032
+ # Required. The resource name of the location associated with the
1033
+ # {Google::Cloud::Kms::V1::KeyRing KeyRings}, in the format `projects/*/locations/*`.
1034
+ # @param key_ring_id [String]
1035
+ # Required. It must be unique within a location and match the regular
1036
+ # expression `[a-zA-Z0-9_-]{1,63}`
1037
+ # @param key_ring [Google::Cloud::Kms::V1::KeyRing, Hash]
1038
+ # Required. A {Google::Cloud::Kms::V1::KeyRing KeyRing} with initial field values.
1039
+ #
1040
+ # @yield [response, operation] Access the result along with the RPC operation
1041
+ # @yieldparam response [Google::Cloud::Kms::V1::KeyRing]
1042
+ # @yieldparam operation [GRPC::ActiveCall::Operation]
1043
+ #
1044
+ # @return [Google::Cloud::Kms::V1::KeyRing]
1045
+ #
1046
+ # @raise [Google::Cloud::Error] if the RPC is aborted.
1047
+ #
1048
+ def create_key_ring request, options = nil
1049
+ raise ArgumentError, "request must be provided" if request.nil?
1050
+
1051
+ request = Gapic::Protobuf.coerce request, to: Google::Cloud::Kms::V1::CreateKeyRingRequest
1052
+
1053
+ # Converts hash and nil to an options object
1054
+ options = Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
1055
+
1056
+ # Customize the options with defaults
1057
+ metadata = @config.rpcs.create_key_ring.metadata.to_h
1058
+
1059
+ # Set x-goog-api-client and x-goog-user-project headers
1060
+ metadata[:"x-goog-api-client"] ||= Gapic::Headers.x_goog_api_client \
1061
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
1062
+ gapic_version: ::Google::Cloud::Kms::V1::VERSION
1063
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
1064
+
1065
+ header_params = {
1066
+ "parent" => request.parent
1067
+ }
1068
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
1069
+ metadata[:"x-goog-request-params"] ||= request_params_header
1070
+
1071
+ options.apply_defaults timeout: @config.rpcs.create_key_ring.timeout,
1072
+ metadata: metadata,
1073
+ retry_policy: @config.rpcs.create_key_ring.retry_policy
1074
+ options.apply_defaults metadata: @config.metadata,
1075
+ retry_policy: @config.retry_policy
1076
+
1077
+ @key_management_service_stub.call_rpc :create_key_ring, request, options: options do |response, operation|
1078
+ yield response, operation if block_given?
1079
+ return response
1080
+ end
1081
+ rescue GRPC::BadStatus => e
1082
+ raise Google::Cloud::Error.from_error(e)
1083
+ end
1084
+
1085
+ ##
1086
+ # Create a new {Google::Cloud::Kms::V1::CryptoKey CryptoKey} within a {Google::Cloud::Kms::V1::KeyRing KeyRing}.
1087
+ #
1088
+ # {Google::Cloud::Kms::V1::CryptoKey#purpose CryptoKey.purpose} and
1089
+ # {Google::Cloud::Kms::V1::CryptoKeyVersionTemplate#algorithm CryptoKey.version_template.algorithm}
1090
+ # are required.
1091
+ #
1092
+ # @overload create_crypto_key(request, options = nil)
1093
+ # Pass arguments to `create_crypto_key` via a request object, either of type
1094
+ # {Google::Cloud::Kms::V1::CreateCryptoKeyRequest} or an equivalent Hash.
1095
+ #
1096
+ # @param request [Google::Cloud::Kms::V1::CreateCryptoKeyRequest, Hash]
1097
+ # A request object representing the call parameters. Required. To specify no
1098
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
1099
+ # @param options [Gapic::CallOptions, Hash]
1100
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
1101
+ #
1102
+ # @overload create_crypto_key(parent: nil, crypto_key_id: nil, crypto_key: nil, skip_initial_version_creation: nil)
1103
+ # Pass arguments to `create_crypto_key` via keyword arguments. Note that at
1104
+ # least one keyword argument is required. To specify no parameters, or to keep all
1105
+ # the default parameter values, pass an empty Hash as a request object (see above).
1106
+ #
1107
+ # @param parent [String]
1108
+ # Required. The {Google::Cloud::Kms::V1::KeyRing#name name} of the KeyRing associated with the
1109
+ # {Google::Cloud::Kms::V1::CryptoKey CryptoKeys}.
1110
+ # @param crypto_key_id [String]
1111
+ # Required. It must be unique within a KeyRing and match the regular
1112
+ # expression `[a-zA-Z0-9_-]{1,63}`
1113
+ # @param crypto_key [Google::Cloud::Kms::V1::CryptoKey, Hash]
1114
+ # Required. A {Google::Cloud::Kms::V1::CryptoKey CryptoKey} with initial field values.
1115
+ # @param skip_initial_version_creation [Boolean]
1116
+ # If set to true, the request will create a {Google::Cloud::Kms::V1::CryptoKey CryptoKey} without any
1117
+ # {Google::Cloud::Kms::V1::CryptoKeyVersion CryptoKeyVersions}. You must manually call
1118
+ # {Google::Cloud::Kms::V1::KeyManagementService::Client#create_crypto_key_version CreateCryptoKeyVersion} or
1119
+ # {Google::Cloud::Kms::V1::KeyManagementService::Client#import_crypto_key_version ImportCryptoKeyVersion}
1120
+ # before you can use this {Google::Cloud::Kms::V1::CryptoKey CryptoKey}.
1121
+ #
1122
+ # @yield [response, operation] Access the result along with the RPC operation
1123
+ # @yieldparam response [Google::Cloud::Kms::V1::CryptoKey]
1124
+ # @yieldparam operation [GRPC::ActiveCall::Operation]
1125
+ #
1126
+ # @return [Google::Cloud::Kms::V1::CryptoKey]
1127
+ #
1128
+ # @raise [Google::Cloud::Error] if the RPC is aborted.
1129
+ #
1130
+ def create_crypto_key request, options = nil
1131
+ raise ArgumentError, "request must be provided" if request.nil?
1132
+
1133
+ request = Gapic::Protobuf.coerce request, to: Google::Cloud::Kms::V1::CreateCryptoKeyRequest
1134
+
1135
+ # Converts hash and nil to an options object
1136
+ options = Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
1137
+
1138
+ # Customize the options with defaults
1139
+ metadata = @config.rpcs.create_crypto_key.metadata.to_h
1140
+
1141
+ # Set x-goog-api-client and x-goog-user-project headers
1142
+ metadata[:"x-goog-api-client"] ||= Gapic::Headers.x_goog_api_client \
1143
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
1144
+ gapic_version: ::Google::Cloud::Kms::V1::VERSION
1145
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
1146
+
1147
+ header_params = {
1148
+ "parent" => request.parent
1149
+ }
1150
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
1151
+ metadata[:"x-goog-request-params"] ||= request_params_header
1152
+
1153
+ options.apply_defaults timeout: @config.rpcs.create_crypto_key.timeout,
1154
+ metadata: metadata,
1155
+ retry_policy: @config.rpcs.create_crypto_key.retry_policy
1156
+ options.apply_defaults metadata: @config.metadata,
1157
+ retry_policy: @config.retry_policy
1158
+
1159
+ @key_management_service_stub.call_rpc :create_crypto_key, request, options: options do |response, operation|
1160
+ yield response, operation if block_given?
1161
+ return response
1162
+ end
1163
+ rescue GRPC::BadStatus => e
1164
+ raise Google::Cloud::Error.from_error(e)
1165
+ end
1166
+
1167
+ ##
1168
+ # Create a new {Google::Cloud::Kms::V1::CryptoKeyVersion CryptoKeyVersion} in a {Google::Cloud::Kms::V1::CryptoKey CryptoKey}.
1169
+ #
1170
+ # The server will assign the next sequential id. If unset,
1171
+ # {Google::Cloud::Kms::V1::CryptoKeyVersion#state state} will be set to
1172
+ # {Google::Cloud::Kms::V1::CryptoKeyVersion::CryptoKeyVersionState::ENABLED ENABLED}.
1173
+ #
1174
+ # @overload create_crypto_key_version(request, options = nil)
1175
+ # Pass arguments to `create_crypto_key_version` via a request object, either of type
1176
+ # {Google::Cloud::Kms::V1::CreateCryptoKeyVersionRequest} or an equivalent Hash.
1177
+ #
1178
+ # @param request [Google::Cloud::Kms::V1::CreateCryptoKeyVersionRequest, Hash]
1179
+ # A request object representing the call parameters. Required. To specify no
1180
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
1181
+ # @param options [Gapic::CallOptions, Hash]
1182
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
1183
+ #
1184
+ # @overload create_crypto_key_version(parent: nil, crypto_key_version: nil)
1185
+ # Pass arguments to `create_crypto_key_version` via keyword arguments. Note that at
1186
+ # least one keyword argument is required. To specify no parameters, or to keep all
1187
+ # the default parameter values, pass an empty Hash as a request object (see above).
1188
+ #
1189
+ # @param parent [String]
1190
+ # Required. The {Google::Cloud::Kms::V1::CryptoKey#name name} of the {Google::Cloud::Kms::V1::CryptoKey CryptoKey} associated with
1191
+ # the {Google::Cloud::Kms::V1::CryptoKeyVersion CryptoKeyVersions}.
1192
+ # @param crypto_key_version [Google::Cloud::Kms::V1::CryptoKeyVersion, Hash]
1193
+ # Required. A {Google::Cloud::Kms::V1::CryptoKeyVersion CryptoKeyVersion} with initial field values.
1194
+ #
1195
+ # @yield [response, operation] Access the result along with the RPC operation
1196
+ # @yieldparam response [Google::Cloud::Kms::V1::CryptoKeyVersion]
1197
+ # @yieldparam operation [GRPC::ActiveCall::Operation]
1198
+ #
1199
+ # @return [Google::Cloud::Kms::V1::CryptoKeyVersion]
1200
+ #
1201
+ # @raise [Google::Cloud::Error] if the RPC is aborted.
1202
+ #
1203
+ def create_crypto_key_version request, options = nil
1204
+ raise ArgumentError, "request must be provided" if request.nil?
1205
+
1206
+ request = Gapic::Protobuf.coerce request, to: Google::Cloud::Kms::V1::CreateCryptoKeyVersionRequest
1207
+
1208
+ # Converts hash and nil to an options object
1209
+ options = Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
1210
+
1211
+ # Customize the options with defaults
1212
+ metadata = @config.rpcs.create_crypto_key_version.metadata.to_h
1213
+
1214
+ # Set x-goog-api-client and x-goog-user-project headers
1215
+ metadata[:"x-goog-api-client"] ||= Gapic::Headers.x_goog_api_client \
1216
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
1217
+ gapic_version: ::Google::Cloud::Kms::V1::VERSION
1218
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
1219
+
1220
+ header_params = {
1221
+ "parent" => request.parent
1222
+ }
1223
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
1224
+ metadata[:"x-goog-request-params"] ||= request_params_header
1225
+
1226
+ options.apply_defaults timeout: @config.rpcs.create_crypto_key_version.timeout,
1227
+ metadata: metadata,
1228
+ retry_policy: @config.rpcs.create_crypto_key_version.retry_policy
1229
+ options.apply_defaults metadata: @config.metadata,
1230
+ retry_policy: @config.retry_policy
1231
+
1232
+ @key_management_service_stub.call_rpc :create_crypto_key_version, request, options: options do |response, operation|
1233
+ yield response, operation if block_given?
1234
+ return response
1235
+ end
1236
+ rescue GRPC::BadStatus => e
1237
+ raise Google::Cloud::Error.from_error(e)
1238
+ end
1239
+
1240
+ ##
1241
+ # Imports a new {Google::Cloud::Kms::V1::CryptoKeyVersion CryptoKeyVersion} into an existing {Google::Cloud::Kms::V1::CryptoKey CryptoKey} using the
1242
+ # wrapped key material provided in the request.
1243
+ #
1244
+ # The version ID will be assigned the next sequential id within the
1245
+ # {Google::Cloud::Kms::V1::CryptoKey CryptoKey}.
1246
+ #
1247
+ # @overload import_crypto_key_version(request, options = nil)
1248
+ # Pass arguments to `import_crypto_key_version` via a request object, either of type
1249
+ # {Google::Cloud::Kms::V1::ImportCryptoKeyVersionRequest} or an equivalent Hash.
1250
+ #
1251
+ # @param request [Google::Cloud::Kms::V1::ImportCryptoKeyVersionRequest, Hash]
1252
+ # A request object representing the call parameters. Required. To specify no
1253
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
1254
+ # @param options [Gapic::CallOptions, Hash]
1255
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
1256
+ #
1257
+ # @overload import_crypto_key_version(parent: nil, algorithm: nil, import_job: nil, rsa_aes_wrapped_key: nil)
1258
+ # Pass arguments to `import_crypto_key_version` via keyword arguments. Note that at
1259
+ # least one keyword argument is required. To specify no parameters, or to keep all
1260
+ # the default parameter values, pass an empty Hash as a request object (see above).
1261
+ #
1262
+ # @param parent [String]
1263
+ # Required. The {Google::Cloud::Kms::V1::CryptoKey#name name} of the {Google::Cloud::Kms::V1::CryptoKey CryptoKey} to
1264
+ # be imported into.
1265
+ # @param algorithm [Google::Cloud::Kms::V1::CryptoKeyVersion::CryptoKeyVersionAlgorithm]
1266
+ # Required. The {Google::Cloud::Kms::V1::CryptoKeyVersion::CryptoKeyVersionAlgorithm algorithm} of
1267
+ # the key being imported. This does not need to match the
1268
+ # {Google::Cloud::Kms::V1::CryptoKey#version_template version_template} of the {Google::Cloud::Kms::V1::CryptoKey CryptoKey} this
1269
+ # version imports into.
1270
+ # @param import_job [String]
1271
+ # Required. The {Google::Cloud::Kms::V1::ImportJob#name name} of the {Google::Cloud::Kms::V1::ImportJob ImportJob} that was used to
1272
+ # wrap this key material.
1273
+ # @param rsa_aes_wrapped_key [String]
1274
+ # Wrapped key material produced with
1275
+ # {Google::Cloud::Kms::V1::ImportJob::ImportMethod::RSA_OAEP_3072_SHA1_AES_256 RSA_OAEP_3072_SHA1_AES_256}
1276
+ # or
1277
+ # {Google::Cloud::Kms::V1::ImportJob::ImportMethod::RSA_OAEP_4096_SHA1_AES_256 RSA_OAEP_4096_SHA1_AES_256}.
1278
+ #
1279
+ # This field contains the concatenation of two wrapped keys:
1280
+ # <ol>
1281
+ # <li>An ephemeral AES-256 wrapping key wrapped with the
1282
+ # {Google::Cloud::Kms::V1::ImportJob#public_key public_key} using RSAES-OAEP with SHA-1,
1283
+ # MGF1 with SHA-1, and an empty label.
1284
+ # </li>
1285
+ # <li>The key to be imported, wrapped with the ephemeral AES-256 key
1286
+ # using AES-KWP (RFC 5649).
1287
+ # </li>
1288
+ # </ol>
1289
+ #
1290
+ # If importing symmetric key material, it is expected that the unwrapped
1291
+ # key contains plain bytes. If importing asymmetric key material, it is
1292
+ # expected that the unwrapped key is in PKCS#8-encoded DER format (the
1293
+ # PrivateKeyInfo structure from RFC 5208).
1294
+ #
1295
+ # This format is the same as the format produced by PKCS#11 mechanism
1296
+ # CKM_RSA_AES_KEY_WRAP.
1297
+ #
1298
+ # @yield [response, operation] Access the result along with the RPC operation
1299
+ # @yieldparam response [Google::Cloud::Kms::V1::CryptoKeyVersion]
1300
+ # @yieldparam operation [GRPC::ActiveCall::Operation]
1301
+ #
1302
+ # @return [Google::Cloud::Kms::V1::CryptoKeyVersion]
1303
+ #
1304
+ # @raise [Google::Cloud::Error] if the RPC is aborted.
1305
+ #
1306
+ def import_crypto_key_version request, options = nil
1307
+ raise ArgumentError, "request must be provided" if request.nil?
1308
+
1309
+ request = Gapic::Protobuf.coerce request, to: Google::Cloud::Kms::V1::ImportCryptoKeyVersionRequest
1310
+
1311
+ # Converts hash and nil to an options object
1312
+ options = Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
1313
+
1314
+ # Customize the options with defaults
1315
+ metadata = @config.rpcs.import_crypto_key_version.metadata.to_h
1316
+
1317
+ # Set x-goog-api-client and x-goog-user-project headers
1318
+ metadata[:"x-goog-api-client"] ||= Gapic::Headers.x_goog_api_client \
1319
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
1320
+ gapic_version: ::Google::Cloud::Kms::V1::VERSION
1321
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
1322
+
1323
+ header_params = {
1324
+ "parent" => request.parent
1325
+ }
1326
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
1327
+ metadata[:"x-goog-request-params"] ||= request_params_header
1328
+
1329
+ options.apply_defaults timeout: @config.rpcs.import_crypto_key_version.timeout,
1330
+ metadata: metadata,
1331
+ retry_policy: @config.rpcs.import_crypto_key_version.retry_policy
1332
+ options.apply_defaults metadata: @config.metadata,
1333
+ retry_policy: @config.retry_policy
1334
+
1335
+ @key_management_service_stub.call_rpc :import_crypto_key_version, request, options: options do |response, operation|
1336
+ yield response, operation if block_given?
1337
+ return response
1338
+ end
1339
+ rescue GRPC::BadStatus => e
1340
+ raise Google::Cloud::Error.from_error(e)
1341
+ end
1342
+
1343
+ ##
1344
+ # Create a new {Google::Cloud::Kms::V1::ImportJob ImportJob} within a {Google::Cloud::Kms::V1::KeyRing KeyRing}.
1345
+ #
1346
+ # {Google::Cloud::Kms::V1::ImportJob#import_method ImportJob.import_method} is required.
1347
+ #
1348
+ # @overload create_import_job(request, options = nil)
1349
+ # Pass arguments to `create_import_job` via a request object, either of type
1350
+ # {Google::Cloud::Kms::V1::CreateImportJobRequest} or an equivalent Hash.
1351
+ #
1352
+ # @param request [Google::Cloud::Kms::V1::CreateImportJobRequest, Hash]
1353
+ # A request object representing the call parameters. Required. To specify no
1354
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
1355
+ # @param options [Gapic::CallOptions, Hash]
1356
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
1357
+ #
1358
+ # @overload create_import_job(parent: nil, import_job_id: nil, import_job: nil)
1359
+ # Pass arguments to `create_import_job` via keyword arguments. Note that at
1360
+ # least one keyword argument is required. To specify no parameters, or to keep all
1361
+ # the default parameter values, pass an empty Hash as a request object (see above).
1362
+ #
1363
+ # @param parent [String]
1364
+ # Required. The {Google::Cloud::Kms::V1::KeyRing#name name} of the {Google::Cloud::Kms::V1::KeyRing KeyRing} associated with the
1365
+ # {Google::Cloud::Kms::V1::ImportJob ImportJobs}.
1366
+ # @param import_job_id [String]
1367
+ # Required. It must be unique within a KeyRing and match the regular
1368
+ # expression `[a-zA-Z0-9_-]{1,63}`
1369
+ # @param import_job [Google::Cloud::Kms::V1::ImportJob, Hash]
1370
+ # Required. An {Google::Cloud::Kms::V1::ImportJob ImportJob} with initial field values.
1371
+ #
1372
+ # @yield [response, operation] Access the result along with the RPC operation
1373
+ # @yieldparam response [Google::Cloud::Kms::V1::ImportJob]
1374
+ # @yieldparam operation [GRPC::ActiveCall::Operation]
1375
+ #
1376
+ # @return [Google::Cloud::Kms::V1::ImportJob]
1377
+ #
1378
+ # @raise [Google::Cloud::Error] if the RPC is aborted.
1379
+ #
1380
+ def create_import_job request, options = nil
1381
+ raise ArgumentError, "request must be provided" if request.nil?
1382
+
1383
+ request = Gapic::Protobuf.coerce request, to: Google::Cloud::Kms::V1::CreateImportJobRequest
1384
+
1385
+ # Converts hash and nil to an options object
1386
+ options = Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
1387
+
1388
+ # Customize the options with defaults
1389
+ metadata = @config.rpcs.create_import_job.metadata.to_h
1390
+
1391
+ # Set x-goog-api-client and x-goog-user-project headers
1392
+ metadata[:"x-goog-api-client"] ||= Gapic::Headers.x_goog_api_client \
1393
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
1394
+ gapic_version: ::Google::Cloud::Kms::V1::VERSION
1395
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
1396
+
1397
+ header_params = {
1398
+ "parent" => request.parent
1399
+ }
1400
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
1401
+ metadata[:"x-goog-request-params"] ||= request_params_header
1402
+
1403
+ options.apply_defaults timeout: @config.rpcs.create_import_job.timeout,
1404
+ metadata: metadata,
1405
+ retry_policy: @config.rpcs.create_import_job.retry_policy
1406
+ options.apply_defaults metadata: @config.metadata,
1407
+ retry_policy: @config.retry_policy
1408
+
1409
+ @key_management_service_stub.call_rpc :create_import_job, request, options: options do |response, operation|
1410
+ yield response, operation if block_given?
1411
+ return response
1412
+ end
1413
+ rescue GRPC::BadStatus => e
1414
+ raise Google::Cloud::Error.from_error(e)
1415
+ end
1416
+
1417
+ ##
1418
+ # Update a {Google::Cloud::Kms::V1::CryptoKey CryptoKey}.
1419
+ #
1420
+ # @overload update_crypto_key(request, options = nil)
1421
+ # Pass arguments to `update_crypto_key` via a request object, either of type
1422
+ # {Google::Cloud::Kms::V1::UpdateCryptoKeyRequest} or an equivalent Hash.
1423
+ #
1424
+ # @param request [Google::Cloud::Kms::V1::UpdateCryptoKeyRequest, Hash]
1425
+ # A request object representing the call parameters. Required. To specify no
1426
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
1427
+ # @param options [Gapic::CallOptions, Hash]
1428
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
1429
+ #
1430
+ # @overload update_crypto_key(crypto_key: nil, update_mask: nil)
1431
+ # Pass arguments to `update_crypto_key` via keyword arguments. Note that at
1432
+ # least one keyword argument is required. To specify no parameters, or to keep all
1433
+ # the default parameter values, pass an empty Hash as a request object (see above).
1434
+ #
1435
+ # @param crypto_key [Google::Cloud::Kms::V1::CryptoKey, Hash]
1436
+ # Required. {Google::Cloud::Kms::V1::CryptoKey CryptoKey} with updated values.
1437
+ # @param update_mask [Google::Protobuf::FieldMask, Hash]
1438
+ # Required. List of fields to be updated in this request.
1439
+ #
1440
+ # @yield [response, operation] Access the result along with the RPC operation
1441
+ # @yieldparam response [Google::Cloud::Kms::V1::CryptoKey]
1442
+ # @yieldparam operation [GRPC::ActiveCall::Operation]
1443
+ #
1444
+ # @return [Google::Cloud::Kms::V1::CryptoKey]
1445
+ #
1446
+ # @raise [Google::Cloud::Error] if the RPC is aborted.
1447
+ #
1448
+ def update_crypto_key request, options = nil
1449
+ raise ArgumentError, "request must be provided" if request.nil?
1450
+
1451
+ request = Gapic::Protobuf.coerce request, to: Google::Cloud::Kms::V1::UpdateCryptoKeyRequest
1452
+
1453
+ # Converts hash and nil to an options object
1454
+ options = Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
1455
+
1456
+ # Customize the options with defaults
1457
+ metadata = @config.rpcs.update_crypto_key.metadata.to_h
1458
+
1459
+ # Set x-goog-api-client and x-goog-user-project headers
1460
+ metadata[:"x-goog-api-client"] ||= Gapic::Headers.x_goog_api_client \
1461
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
1462
+ gapic_version: ::Google::Cloud::Kms::V1::VERSION
1463
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
1464
+
1465
+ header_params = {
1466
+ "crypto_key.name" => request.crypto_key.name
1467
+ }
1468
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
1469
+ metadata[:"x-goog-request-params"] ||= request_params_header
1470
+
1471
+ options.apply_defaults timeout: @config.rpcs.update_crypto_key.timeout,
1472
+ metadata: metadata,
1473
+ retry_policy: @config.rpcs.update_crypto_key.retry_policy
1474
+ options.apply_defaults metadata: @config.metadata,
1475
+ retry_policy: @config.retry_policy
1476
+
1477
+ @key_management_service_stub.call_rpc :update_crypto_key, request, options: options do |response, operation|
1478
+ yield response, operation if block_given?
1479
+ return response
1480
+ end
1481
+ rescue GRPC::BadStatus => e
1482
+ raise Google::Cloud::Error.from_error(e)
1483
+ end
1484
+
1485
+ ##
1486
+ # Update a {Google::Cloud::Kms::V1::CryptoKeyVersion CryptoKeyVersion}'s metadata.
1487
+ #
1488
+ # {Google::Cloud::Kms::V1::CryptoKeyVersion#state state} may be changed between
1489
+ # {Google::Cloud::Kms::V1::CryptoKeyVersion::CryptoKeyVersionState::ENABLED ENABLED} and
1490
+ # {Google::Cloud::Kms::V1::CryptoKeyVersion::CryptoKeyVersionState::DISABLED DISABLED} using this
1491
+ # method. See {Google::Cloud::Kms::V1::KeyManagementService::Client#destroy_crypto_key_version DestroyCryptoKeyVersion} and {Google::Cloud::Kms::V1::KeyManagementService::Client#restore_crypto_key_version RestoreCryptoKeyVersion} to
1492
+ # move between other states.
1493
+ #
1494
+ # @overload update_crypto_key_version(request, options = nil)
1495
+ # Pass arguments to `update_crypto_key_version` via a request object, either of type
1496
+ # {Google::Cloud::Kms::V1::UpdateCryptoKeyVersionRequest} or an equivalent Hash.
1497
+ #
1498
+ # @param request [Google::Cloud::Kms::V1::UpdateCryptoKeyVersionRequest, Hash]
1499
+ # A request object representing the call parameters. Required. To specify no
1500
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
1501
+ # @param options [Gapic::CallOptions, Hash]
1502
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
1503
+ #
1504
+ # @overload update_crypto_key_version(crypto_key_version: nil, update_mask: nil)
1505
+ # Pass arguments to `update_crypto_key_version` via keyword arguments. Note that at
1506
+ # least one keyword argument is required. To specify no parameters, or to keep all
1507
+ # the default parameter values, pass an empty Hash as a request object (see above).
1508
+ #
1509
+ # @param crypto_key_version [Google::Cloud::Kms::V1::CryptoKeyVersion, Hash]
1510
+ # Required. {Google::Cloud::Kms::V1::CryptoKeyVersion CryptoKeyVersion} with updated values.
1511
+ # @param update_mask [Google::Protobuf::FieldMask, Hash]
1512
+ # Required. List of fields to be updated in this request.
1513
+ #
1514
+ # @yield [response, operation] Access the result along with the RPC operation
1515
+ # @yieldparam response [Google::Cloud::Kms::V1::CryptoKeyVersion]
1516
+ # @yieldparam operation [GRPC::ActiveCall::Operation]
1517
+ #
1518
+ # @return [Google::Cloud::Kms::V1::CryptoKeyVersion]
1519
+ #
1520
+ # @raise [Google::Cloud::Error] if the RPC is aborted.
1521
+ #
1522
+ def update_crypto_key_version request, options = nil
1523
+ raise ArgumentError, "request must be provided" if request.nil?
1524
+
1525
+ request = Gapic::Protobuf.coerce request, to: Google::Cloud::Kms::V1::UpdateCryptoKeyVersionRequest
1526
+
1527
+ # Converts hash and nil to an options object
1528
+ options = Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
1529
+
1530
+ # Customize the options with defaults
1531
+ metadata = @config.rpcs.update_crypto_key_version.metadata.to_h
1532
+
1533
+ # Set x-goog-api-client and x-goog-user-project headers
1534
+ metadata[:"x-goog-api-client"] ||= Gapic::Headers.x_goog_api_client \
1535
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
1536
+ gapic_version: ::Google::Cloud::Kms::V1::VERSION
1537
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
1538
+
1539
+ header_params = {
1540
+ "crypto_key_version.name" => request.crypto_key_version.name
1541
+ }
1542
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
1543
+ metadata[:"x-goog-request-params"] ||= request_params_header
1544
+
1545
+ options.apply_defaults timeout: @config.rpcs.update_crypto_key_version.timeout,
1546
+ metadata: metadata,
1547
+ retry_policy: @config.rpcs.update_crypto_key_version.retry_policy
1548
+ options.apply_defaults metadata: @config.metadata,
1549
+ retry_policy: @config.retry_policy
1550
+
1551
+ @key_management_service_stub.call_rpc :update_crypto_key_version, request, options: options do |response, operation|
1552
+ yield response, operation if block_given?
1553
+ return response
1554
+ end
1555
+ rescue GRPC::BadStatus => e
1556
+ raise Google::Cloud::Error.from_error(e)
1557
+ end
1558
+
1559
+ ##
1560
+ # Encrypts data, so that it can only be recovered by a call to {Google::Cloud::Kms::V1::KeyManagementService::Client#decrypt Decrypt}.
1561
+ # The {Google::Cloud::Kms::V1::CryptoKey#purpose CryptoKey.purpose} must be
1562
+ # {Google::Cloud::Kms::V1::CryptoKey::CryptoKeyPurpose::ENCRYPT_DECRYPT ENCRYPT_DECRYPT}.
1563
+ #
1564
+ # @overload encrypt(request, options = nil)
1565
+ # Pass arguments to `encrypt` via a request object, either of type
1566
+ # {Google::Cloud::Kms::V1::EncryptRequest} or an equivalent Hash.
1567
+ #
1568
+ # @param request [Google::Cloud::Kms::V1::EncryptRequest, Hash]
1569
+ # A request object representing the call parameters. Required. To specify no
1570
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
1571
+ # @param options [Gapic::CallOptions, Hash]
1572
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
1573
+ #
1574
+ # @overload encrypt(name: nil, plaintext: nil, additional_authenticated_data: nil)
1575
+ # Pass arguments to `encrypt` via keyword arguments. Note that at
1576
+ # least one keyword argument is required. To specify no parameters, or to keep all
1577
+ # the default parameter values, pass an empty Hash as a request object (see above).
1578
+ #
1579
+ # @param name [String]
1580
+ # Required. The resource name of the {Google::Cloud::Kms::V1::CryptoKey CryptoKey} or {Google::Cloud::Kms::V1::CryptoKeyVersion CryptoKeyVersion}
1581
+ # to use for encryption.
1582
+ #
1583
+ # If a {Google::Cloud::Kms::V1::CryptoKey CryptoKey} is specified, the server will use its
1584
+ # {Google::Cloud::Kms::V1::CryptoKey#primary primary version}.
1585
+ # @param plaintext [String]
1586
+ # Required. The data to encrypt. Must be no larger than 64KiB.
1587
+ #
1588
+ # The maximum size depends on the key version's
1589
+ # {Google::Cloud::Kms::V1::CryptoKeyVersionTemplate#protection_level protection_level}. For
1590
+ # {Google::Cloud::Kms::V1::ProtectionLevel::SOFTWARE SOFTWARE} keys, the plaintext must be no larger
1591
+ # than 64KiB. For {Google::Cloud::Kms::V1::ProtectionLevel::HSM HSM} keys, the combined length of the
1592
+ # plaintext and additional_authenticated_data fields must be no larger than
1593
+ # 8KiB.
1594
+ # @param additional_authenticated_data [String]
1595
+ # Optional. Optional data that, if specified, must also be provided during decryption
1596
+ # through {Google::Cloud::Kms::V1::DecryptRequest#additional_authenticated_data DecryptRequest.additional_authenticated_data}.
1597
+ #
1598
+ # The maximum size depends on the key version's
1599
+ # {Google::Cloud::Kms::V1::CryptoKeyVersionTemplate#protection_level protection_level}. For
1600
+ # {Google::Cloud::Kms::V1::ProtectionLevel::SOFTWARE SOFTWARE} keys, the AAD must be no larger than
1601
+ # 64KiB. For {Google::Cloud::Kms::V1::ProtectionLevel::HSM HSM} keys, the combined length of the
1602
+ # plaintext and additional_authenticated_data fields must be no larger than
1603
+ # 8KiB.
1604
+ #
1605
+ # @yield [response, operation] Access the result along with the RPC operation
1606
+ # @yieldparam response [Google::Cloud::Kms::V1::EncryptResponse]
1607
+ # @yieldparam operation [GRPC::ActiveCall::Operation]
1608
+ #
1609
+ # @return [Google::Cloud::Kms::V1::EncryptResponse]
1610
+ #
1611
+ # @raise [Google::Cloud::Error] if the RPC is aborted.
1612
+ #
1613
+ def encrypt request, options = nil
1614
+ raise ArgumentError, "request must be provided" if request.nil?
1615
+
1616
+ request = Gapic::Protobuf.coerce request, to: Google::Cloud::Kms::V1::EncryptRequest
1617
+
1618
+ # Converts hash and nil to an options object
1619
+ options = Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
1620
+
1621
+ # Customize the options with defaults
1622
+ metadata = @config.rpcs.encrypt.metadata.to_h
1623
+
1624
+ # Set x-goog-api-client and x-goog-user-project headers
1625
+ metadata[:"x-goog-api-client"] ||= Gapic::Headers.x_goog_api_client \
1626
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
1627
+ gapic_version: ::Google::Cloud::Kms::V1::VERSION
1628
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
1629
+
1630
+ header_params = {
1631
+ "name" => request.name
1632
+ }
1633
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
1634
+ metadata[:"x-goog-request-params"] ||= request_params_header
1635
+
1636
+ options.apply_defaults timeout: @config.rpcs.encrypt.timeout,
1637
+ metadata: metadata,
1638
+ retry_policy: @config.rpcs.encrypt.retry_policy
1639
+ options.apply_defaults metadata: @config.metadata,
1640
+ retry_policy: @config.retry_policy
1641
+
1642
+ @key_management_service_stub.call_rpc :encrypt, request, options: options do |response, operation|
1643
+ yield response, operation if block_given?
1644
+ return response
1645
+ end
1646
+ rescue GRPC::BadStatus => e
1647
+ raise Google::Cloud::Error.from_error(e)
1648
+ end
1649
+
1650
+ ##
1651
+ # Decrypts data that was protected by {Google::Cloud::Kms::V1::KeyManagementService::Client#encrypt Encrypt}. The {Google::Cloud::Kms::V1::CryptoKey#purpose CryptoKey.purpose}
1652
+ # must be {Google::Cloud::Kms::V1::CryptoKey::CryptoKeyPurpose::ENCRYPT_DECRYPT ENCRYPT_DECRYPT}.
1653
+ #
1654
+ # @overload decrypt(request, options = nil)
1655
+ # Pass arguments to `decrypt` via a request object, either of type
1656
+ # {Google::Cloud::Kms::V1::DecryptRequest} or an equivalent Hash.
1657
+ #
1658
+ # @param request [Google::Cloud::Kms::V1::DecryptRequest, Hash]
1659
+ # A request object representing the call parameters. Required. To specify no
1660
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
1661
+ # @param options [Gapic::CallOptions, Hash]
1662
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
1663
+ #
1664
+ # @overload decrypt(name: nil, ciphertext: nil, additional_authenticated_data: nil)
1665
+ # Pass arguments to `decrypt` via keyword arguments. Note that at
1666
+ # least one keyword argument is required. To specify no parameters, or to keep all
1667
+ # the default parameter values, pass an empty Hash as a request object (see above).
1668
+ #
1669
+ # @param name [String]
1670
+ # Required. The resource name of the {Google::Cloud::Kms::V1::CryptoKey CryptoKey} to use for decryption.
1671
+ # The server will choose the appropriate version.
1672
+ # @param ciphertext [String]
1673
+ # Required. The encrypted data originally returned in
1674
+ # {Google::Cloud::Kms::V1::EncryptResponse#ciphertext EncryptResponse.ciphertext}.
1675
+ # @param additional_authenticated_data [String]
1676
+ # Optional. Optional data that must match the data originally supplied in
1677
+ # {Google::Cloud::Kms::V1::EncryptRequest#additional_authenticated_data EncryptRequest.additional_authenticated_data}.
1678
+ #
1679
+ # @yield [response, operation] Access the result along with the RPC operation
1680
+ # @yieldparam response [Google::Cloud::Kms::V1::DecryptResponse]
1681
+ # @yieldparam operation [GRPC::ActiveCall::Operation]
1682
+ #
1683
+ # @return [Google::Cloud::Kms::V1::DecryptResponse]
1684
+ #
1685
+ # @raise [Google::Cloud::Error] if the RPC is aborted.
1686
+ #
1687
+ def decrypt request, options = nil
1688
+ raise ArgumentError, "request must be provided" if request.nil?
1689
+
1690
+ request = Gapic::Protobuf.coerce request, to: Google::Cloud::Kms::V1::DecryptRequest
1691
+
1692
+ # Converts hash and nil to an options object
1693
+ options = Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
1694
+
1695
+ # Customize the options with defaults
1696
+ metadata = @config.rpcs.decrypt.metadata.to_h
1697
+
1698
+ # Set x-goog-api-client and x-goog-user-project headers
1699
+ metadata[:"x-goog-api-client"] ||= Gapic::Headers.x_goog_api_client \
1700
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
1701
+ gapic_version: ::Google::Cloud::Kms::V1::VERSION
1702
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
1703
+
1704
+ header_params = {
1705
+ "name" => request.name
1706
+ }
1707
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
1708
+ metadata[:"x-goog-request-params"] ||= request_params_header
1709
+
1710
+ options.apply_defaults timeout: @config.rpcs.decrypt.timeout,
1711
+ metadata: metadata,
1712
+ retry_policy: @config.rpcs.decrypt.retry_policy
1713
+ options.apply_defaults metadata: @config.metadata,
1714
+ retry_policy: @config.retry_policy
1715
+
1716
+ @key_management_service_stub.call_rpc :decrypt, request, options: options do |response, operation|
1717
+ yield response, operation if block_given?
1718
+ return response
1719
+ end
1720
+ rescue GRPC::BadStatus => e
1721
+ raise Google::Cloud::Error.from_error(e)
1722
+ end
1723
+
1724
+ ##
1725
+ # Signs data using a {Google::Cloud::Kms::V1::CryptoKeyVersion CryptoKeyVersion} with {Google::Cloud::Kms::V1::CryptoKey#purpose CryptoKey.purpose}
1726
+ # ASYMMETRIC_SIGN, producing a signature that can be verified with the public
1727
+ # key retrieved from {Google::Cloud::Kms::V1::KeyManagementService::Client#get_public_key GetPublicKey}.
1728
+ #
1729
+ # @overload asymmetric_sign(request, options = nil)
1730
+ # Pass arguments to `asymmetric_sign` via a request object, either of type
1731
+ # {Google::Cloud::Kms::V1::AsymmetricSignRequest} or an equivalent Hash.
1732
+ #
1733
+ # @param request [Google::Cloud::Kms::V1::AsymmetricSignRequest, Hash]
1734
+ # A request object representing the call parameters. Required. To specify no
1735
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
1736
+ # @param options [Gapic::CallOptions, Hash]
1737
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
1738
+ #
1739
+ # @overload asymmetric_sign(name: nil, digest: nil)
1740
+ # Pass arguments to `asymmetric_sign` via keyword arguments. Note that at
1741
+ # least one keyword argument is required. To specify no parameters, or to keep all
1742
+ # the default parameter values, pass an empty Hash as a request object (see above).
1743
+ #
1744
+ # @param name [String]
1745
+ # Required. The resource name of the {Google::Cloud::Kms::V1::CryptoKeyVersion CryptoKeyVersion} to use for signing.
1746
+ # @param digest [Google::Cloud::Kms::V1::Digest, Hash]
1747
+ # Required. The digest of the data to sign. The digest must be produced with
1748
+ # the same digest algorithm as specified by the key version's
1749
+ # {Google::Cloud::Kms::V1::CryptoKeyVersion#algorithm algorithm}.
1750
+ #
1751
+ # @yield [response, operation] Access the result along with the RPC operation
1752
+ # @yieldparam response [Google::Cloud::Kms::V1::AsymmetricSignResponse]
1753
+ # @yieldparam operation [GRPC::ActiveCall::Operation]
1754
+ #
1755
+ # @return [Google::Cloud::Kms::V1::AsymmetricSignResponse]
1756
+ #
1757
+ # @raise [Google::Cloud::Error] if the RPC is aborted.
1758
+ #
1759
+ def asymmetric_sign request, options = nil
1760
+ raise ArgumentError, "request must be provided" if request.nil?
1761
+
1762
+ request = Gapic::Protobuf.coerce request, to: Google::Cloud::Kms::V1::AsymmetricSignRequest
1763
+
1764
+ # Converts hash and nil to an options object
1765
+ options = Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
1766
+
1767
+ # Customize the options with defaults
1768
+ metadata = @config.rpcs.asymmetric_sign.metadata.to_h
1769
+
1770
+ # Set x-goog-api-client and x-goog-user-project headers
1771
+ metadata[:"x-goog-api-client"] ||= Gapic::Headers.x_goog_api_client \
1772
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
1773
+ gapic_version: ::Google::Cloud::Kms::V1::VERSION
1774
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
1775
+
1776
+ header_params = {
1777
+ "name" => request.name
1778
+ }
1779
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
1780
+ metadata[:"x-goog-request-params"] ||= request_params_header
1781
+
1782
+ options.apply_defaults timeout: @config.rpcs.asymmetric_sign.timeout,
1783
+ metadata: metadata,
1784
+ retry_policy: @config.rpcs.asymmetric_sign.retry_policy
1785
+ options.apply_defaults metadata: @config.metadata,
1786
+ retry_policy: @config.retry_policy
1787
+
1788
+ @key_management_service_stub.call_rpc :asymmetric_sign, request, options: options do |response, operation|
1789
+ yield response, operation if block_given?
1790
+ return response
1791
+ end
1792
+ rescue GRPC::BadStatus => e
1793
+ raise Google::Cloud::Error.from_error(e)
1794
+ end
1795
+
1796
+ ##
1797
+ # Decrypts data that was encrypted with a public key retrieved from
1798
+ # {Google::Cloud::Kms::V1::KeyManagementService::Client#get_public_key GetPublicKey} corresponding to a {Google::Cloud::Kms::V1::CryptoKeyVersion CryptoKeyVersion} with
1799
+ # {Google::Cloud::Kms::V1::CryptoKey#purpose CryptoKey.purpose} ASYMMETRIC_DECRYPT.
1800
+ #
1801
+ # @overload asymmetric_decrypt(request, options = nil)
1802
+ # Pass arguments to `asymmetric_decrypt` via a request object, either of type
1803
+ # {Google::Cloud::Kms::V1::AsymmetricDecryptRequest} or an equivalent Hash.
1804
+ #
1805
+ # @param request [Google::Cloud::Kms::V1::AsymmetricDecryptRequest, Hash]
1806
+ # A request object representing the call parameters. Required. To specify no
1807
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
1808
+ # @param options [Gapic::CallOptions, Hash]
1809
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
1810
+ #
1811
+ # @overload asymmetric_decrypt(name: nil, ciphertext: nil)
1812
+ # Pass arguments to `asymmetric_decrypt` via keyword arguments. Note that at
1813
+ # least one keyword argument is required. To specify no parameters, or to keep all
1814
+ # the default parameter values, pass an empty Hash as a request object (see above).
1815
+ #
1816
+ # @param name [String]
1817
+ # Required. The resource name of the {Google::Cloud::Kms::V1::CryptoKeyVersion CryptoKeyVersion} to use for
1818
+ # decryption.
1819
+ # @param ciphertext [String]
1820
+ # Required. The data encrypted with the named {Google::Cloud::Kms::V1::CryptoKeyVersion CryptoKeyVersion}'s public
1821
+ # key using OAEP.
1822
+ #
1823
+ # @yield [response, operation] Access the result along with the RPC operation
1824
+ # @yieldparam response [Google::Cloud::Kms::V1::AsymmetricDecryptResponse]
1825
+ # @yieldparam operation [GRPC::ActiveCall::Operation]
1826
+ #
1827
+ # @return [Google::Cloud::Kms::V1::AsymmetricDecryptResponse]
1828
+ #
1829
+ # @raise [Google::Cloud::Error] if the RPC is aborted.
1830
+ #
1831
+ def asymmetric_decrypt request, options = nil
1832
+ raise ArgumentError, "request must be provided" if request.nil?
1833
+
1834
+ request = Gapic::Protobuf.coerce request, to: Google::Cloud::Kms::V1::AsymmetricDecryptRequest
1835
+
1836
+ # Converts hash and nil to an options object
1837
+ options = Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
1838
+
1839
+ # Customize the options with defaults
1840
+ metadata = @config.rpcs.asymmetric_decrypt.metadata.to_h
1841
+
1842
+ # Set x-goog-api-client and x-goog-user-project headers
1843
+ metadata[:"x-goog-api-client"] ||= Gapic::Headers.x_goog_api_client \
1844
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
1845
+ gapic_version: ::Google::Cloud::Kms::V1::VERSION
1846
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
1847
+
1848
+ header_params = {
1849
+ "name" => request.name
1850
+ }
1851
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
1852
+ metadata[:"x-goog-request-params"] ||= request_params_header
1853
+
1854
+ options.apply_defaults timeout: @config.rpcs.asymmetric_decrypt.timeout,
1855
+ metadata: metadata,
1856
+ retry_policy: @config.rpcs.asymmetric_decrypt.retry_policy
1857
+ options.apply_defaults metadata: @config.metadata,
1858
+ retry_policy: @config.retry_policy
1859
+
1860
+ @key_management_service_stub.call_rpc :asymmetric_decrypt, request, options: options do |response, operation|
1861
+ yield response, operation if block_given?
1862
+ return response
1863
+ end
1864
+ rescue GRPC::BadStatus => e
1865
+ raise Google::Cloud::Error.from_error(e)
1866
+ end
1867
+
1868
+ ##
1869
+ # Update the version of a {Google::Cloud::Kms::V1::CryptoKey CryptoKey} that will be used in {Google::Cloud::Kms::V1::KeyManagementService::Client#encrypt Encrypt}.
1870
+ #
1871
+ # Returns an error if called on an asymmetric key.
1872
+ #
1873
+ # @overload update_crypto_key_primary_version(request, options = nil)
1874
+ # Pass arguments to `update_crypto_key_primary_version` via a request object, either of type
1875
+ # {Google::Cloud::Kms::V1::UpdateCryptoKeyPrimaryVersionRequest} or an equivalent Hash.
1876
+ #
1877
+ # @param request [Google::Cloud::Kms::V1::UpdateCryptoKeyPrimaryVersionRequest, Hash]
1878
+ # A request object representing the call parameters. Required. To specify no
1879
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
1880
+ # @param options [Gapic::CallOptions, Hash]
1881
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
1882
+ #
1883
+ # @overload update_crypto_key_primary_version(name: nil, crypto_key_version_id: nil)
1884
+ # Pass arguments to `update_crypto_key_primary_version` via keyword arguments. Note that at
1885
+ # least one keyword argument is required. To specify no parameters, or to keep all
1886
+ # the default parameter values, pass an empty Hash as a request object (see above).
1887
+ #
1888
+ # @param name [String]
1889
+ # Required. The resource name of the {Google::Cloud::Kms::V1::CryptoKey CryptoKey} to update.
1890
+ # @param crypto_key_version_id [String]
1891
+ # Required. The id of the child {Google::Cloud::Kms::V1::CryptoKeyVersion CryptoKeyVersion} to use as primary.
1892
+ #
1893
+ # @yield [response, operation] Access the result along with the RPC operation
1894
+ # @yieldparam response [Google::Cloud::Kms::V1::CryptoKey]
1895
+ # @yieldparam operation [GRPC::ActiveCall::Operation]
1896
+ #
1897
+ # @return [Google::Cloud::Kms::V1::CryptoKey]
1898
+ #
1899
+ # @raise [Google::Cloud::Error] if the RPC is aborted.
1900
+ #
1901
+ def update_crypto_key_primary_version request, options = nil
1902
+ raise ArgumentError, "request must be provided" if request.nil?
1903
+
1904
+ request = Gapic::Protobuf.coerce request, to: Google::Cloud::Kms::V1::UpdateCryptoKeyPrimaryVersionRequest
1905
+
1906
+ # Converts hash and nil to an options object
1907
+ options = Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
1908
+
1909
+ # Customize the options with defaults
1910
+ metadata = @config.rpcs.update_crypto_key_primary_version.metadata.to_h
1911
+
1912
+ # Set x-goog-api-client and x-goog-user-project headers
1913
+ metadata[:"x-goog-api-client"] ||= Gapic::Headers.x_goog_api_client \
1914
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
1915
+ gapic_version: ::Google::Cloud::Kms::V1::VERSION
1916
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
1917
+
1918
+ header_params = {
1919
+ "name" => request.name
1920
+ }
1921
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
1922
+ metadata[:"x-goog-request-params"] ||= request_params_header
1923
+
1924
+ options.apply_defaults timeout: @config.rpcs.update_crypto_key_primary_version.timeout,
1925
+ metadata: metadata,
1926
+ retry_policy: @config.rpcs.update_crypto_key_primary_version.retry_policy
1927
+ options.apply_defaults metadata: @config.metadata,
1928
+ retry_policy: @config.retry_policy
1929
+
1930
+ @key_management_service_stub.call_rpc :update_crypto_key_primary_version, request, options: options do |response, operation|
1931
+ yield response, operation if block_given?
1932
+ return response
1933
+ end
1934
+ rescue GRPC::BadStatus => e
1935
+ raise Google::Cloud::Error.from_error(e)
1936
+ end
1937
+
1938
+ ##
1939
+ # Schedule a {Google::Cloud::Kms::V1::CryptoKeyVersion CryptoKeyVersion} for destruction.
1940
+ #
1941
+ # Upon calling this method, {Google::Cloud::Kms::V1::CryptoKeyVersion#state CryptoKeyVersion.state} will be set to
1942
+ # {Google::Cloud::Kms::V1::CryptoKeyVersion::CryptoKeyVersionState::DESTROY_SCHEDULED DESTROY_SCHEDULED}
1943
+ # and {Google::Cloud::Kms::V1::CryptoKeyVersion#destroy_time destroy_time} will be set to a time 24
1944
+ # hours in the future, at which point the {Google::Cloud::Kms::V1::CryptoKeyVersion#state state}
1945
+ # will be changed to
1946
+ # {Google::Cloud::Kms::V1::CryptoKeyVersion::CryptoKeyVersionState::DESTROYED DESTROYED}, and the key
1947
+ # material will be irrevocably destroyed.
1948
+ #
1949
+ # Before the {Google::Cloud::Kms::V1::CryptoKeyVersion#destroy_time destroy_time} is reached,
1950
+ # {Google::Cloud::Kms::V1::KeyManagementService::Client#restore_crypto_key_version RestoreCryptoKeyVersion} may be called to reverse the process.
1951
+ #
1952
+ # @overload destroy_crypto_key_version(request, options = nil)
1953
+ # Pass arguments to `destroy_crypto_key_version` via a request object, either of type
1954
+ # {Google::Cloud::Kms::V1::DestroyCryptoKeyVersionRequest} or an equivalent Hash.
1955
+ #
1956
+ # @param request [Google::Cloud::Kms::V1::DestroyCryptoKeyVersionRequest, Hash]
1957
+ # A request object representing the call parameters. Required. To specify no
1958
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
1959
+ # @param options [Gapic::CallOptions, Hash]
1960
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
1961
+ #
1962
+ # @overload destroy_crypto_key_version(name: nil)
1963
+ # Pass arguments to `destroy_crypto_key_version` via keyword arguments. Note that at
1964
+ # least one keyword argument is required. To specify no parameters, or to keep all
1965
+ # the default parameter values, pass an empty Hash as a request object (see above).
1966
+ #
1967
+ # @param name [String]
1968
+ # Required. The resource name of the {Google::Cloud::Kms::V1::CryptoKeyVersion CryptoKeyVersion} to destroy.
1969
+ #
1970
+ # @yield [response, operation] Access the result along with the RPC operation
1971
+ # @yieldparam response [Google::Cloud::Kms::V1::CryptoKeyVersion]
1972
+ # @yieldparam operation [GRPC::ActiveCall::Operation]
1973
+ #
1974
+ # @return [Google::Cloud::Kms::V1::CryptoKeyVersion]
1975
+ #
1976
+ # @raise [Google::Cloud::Error] if the RPC is aborted.
1977
+ #
1978
+ def destroy_crypto_key_version request, options = nil
1979
+ raise ArgumentError, "request must be provided" if request.nil?
1980
+
1981
+ request = Gapic::Protobuf.coerce request, to: Google::Cloud::Kms::V1::DestroyCryptoKeyVersionRequest
1982
+
1983
+ # Converts hash and nil to an options object
1984
+ options = Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
1985
+
1986
+ # Customize the options with defaults
1987
+ metadata = @config.rpcs.destroy_crypto_key_version.metadata.to_h
1988
+
1989
+ # Set x-goog-api-client and x-goog-user-project headers
1990
+ metadata[:"x-goog-api-client"] ||= Gapic::Headers.x_goog_api_client \
1991
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
1992
+ gapic_version: ::Google::Cloud::Kms::V1::VERSION
1993
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
1994
+
1995
+ header_params = {
1996
+ "name" => request.name
1997
+ }
1998
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
1999
+ metadata[:"x-goog-request-params"] ||= request_params_header
2000
+
2001
+ options.apply_defaults timeout: @config.rpcs.destroy_crypto_key_version.timeout,
2002
+ metadata: metadata,
2003
+ retry_policy: @config.rpcs.destroy_crypto_key_version.retry_policy
2004
+ options.apply_defaults metadata: @config.metadata,
2005
+ retry_policy: @config.retry_policy
2006
+
2007
+ @key_management_service_stub.call_rpc :destroy_crypto_key_version, request, options: options do |response, operation|
2008
+ yield response, operation if block_given?
2009
+ return response
2010
+ end
2011
+ rescue GRPC::BadStatus => e
2012
+ raise Google::Cloud::Error.from_error(e)
2013
+ end
2014
+
2015
+ ##
2016
+ # Restore a {Google::Cloud::Kms::V1::CryptoKeyVersion CryptoKeyVersion} in the
2017
+ # {Google::Cloud::Kms::V1::CryptoKeyVersion::CryptoKeyVersionState::DESTROY_SCHEDULED DESTROY_SCHEDULED}
2018
+ # state.
2019
+ #
2020
+ # Upon restoration of the CryptoKeyVersion, {Google::Cloud::Kms::V1::CryptoKeyVersion#state state}
2021
+ # will be set to {Google::Cloud::Kms::V1::CryptoKeyVersion::CryptoKeyVersionState::DISABLED DISABLED},
2022
+ # and {Google::Cloud::Kms::V1::CryptoKeyVersion#destroy_time destroy_time} will be cleared.
2023
+ #
2024
+ # @overload restore_crypto_key_version(request, options = nil)
2025
+ # Pass arguments to `restore_crypto_key_version` via a request object, either of type
2026
+ # {Google::Cloud::Kms::V1::RestoreCryptoKeyVersionRequest} or an equivalent Hash.
2027
+ #
2028
+ # @param request [Google::Cloud::Kms::V1::RestoreCryptoKeyVersionRequest, Hash]
2029
+ # A request object representing the call parameters. Required. To specify no
2030
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
2031
+ # @param options [Gapic::CallOptions, Hash]
2032
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
2033
+ #
2034
+ # @overload restore_crypto_key_version(name: nil)
2035
+ # Pass arguments to `restore_crypto_key_version` via keyword arguments. Note that at
2036
+ # least one keyword argument is required. To specify no parameters, or to keep all
2037
+ # the default parameter values, pass an empty Hash as a request object (see above).
2038
+ #
2039
+ # @param name [String]
2040
+ # Required. The resource name of the {Google::Cloud::Kms::V1::CryptoKeyVersion CryptoKeyVersion} to restore.
2041
+ #
2042
+ # @yield [response, operation] Access the result along with the RPC operation
2043
+ # @yieldparam response [Google::Cloud::Kms::V1::CryptoKeyVersion]
2044
+ # @yieldparam operation [GRPC::ActiveCall::Operation]
2045
+ #
2046
+ # @return [Google::Cloud::Kms::V1::CryptoKeyVersion]
2047
+ #
2048
+ # @raise [Google::Cloud::Error] if the RPC is aborted.
2049
+ #
2050
+ def restore_crypto_key_version request, options = nil
2051
+ raise ArgumentError, "request must be provided" if request.nil?
2052
+
2053
+ request = Gapic::Protobuf.coerce request, to: Google::Cloud::Kms::V1::RestoreCryptoKeyVersionRequest
2054
+
2055
+ # Converts hash and nil to an options object
2056
+ options = Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
2057
+
2058
+ # Customize the options with defaults
2059
+ metadata = @config.rpcs.restore_crypto_key_version.metadata.to_h
2060
+
2061
+ # Set x-goog-api-client and x-goog-user-project headers
2062
+ metadata[:"x-goog-api-client"] ||= Gapic::Headers.x_goog_api_client \
2063
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
2064
+ gapic_version: ::Google::Cloud::Kms::V1::VERSION
2065
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
2066
+
2067
+ header_params = {
2068
+ "name" => request.name
2069
+ }
2070
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
2071
+ metadata[:"x-goog-request-params"] ||= request_params_header
2072
+
2073
+ options.apply_defaults timeout: @config.rpcs.restore_crypto_key_version.timeout,
2074
+ metadata: metadata,
2075
+ retry_policy: @config.rpcs.restore_crypto_key_version.retry_policy
2076
+ options.apply_defaults metadata: @config.metadata,
2077
+ retry_policy: @config.retry_policy
2078
+
2079
+ @key_management_service_stub.call_rpc :restore_crypto_key_version, request, options: options do |response, operation|
2080
+ yield response, operation if block_given?
2081
+ return response
2082
+ end
2083
+ rescue GRPC::BadStatus => e
2084
+ raise Google::Cloud::Error.from_error(e)
2085
+ end
2086
+
2087
+ ##
2088
+ # Configuration class for the KeyManagementService API.
2089
+ #
2090
+ # This class represents the configuration for KeyManagementService,
2091
+ # providing control over timeouts, retry behavior, logging, transport
2092
+ # parameters, and other low-level controls. Certain parameters can also be
2093
+ # applied individually to specific RPCs. See
2094
+ # {Google::Cloud::Kms::V1::KeyManagementService::Client::Configuration::Rpcs}
2095
+ # for a list of RPCs that can be configured independently.
2096
+ #
2097
+ # Configuration can be applied globally to all clients, or to a single client
2098
+ # on construction.
2099
+ #
2100
+ # # Examples
2101
+ #
2102
+ # To modify the global config, setting the timeout for list_key_rings
2103
+ # to 20 seconds, and all remaining timeouts to 10 seconds:
2104
+ #
2105
+ # Google::Cloud::Kms::V1::KeyManagementService::Client.configure do |config|
2106
+ # config.timeout = 10_000
2107
+ # config.rpcs.list_key_rings.timeout = 20_000
2108
+ # end
2109
+ #
2110
+ # To apply the above configuration only to a new client:
2111
+ #
2112
+ # client = Google::Cloud::Kms::V1::KeyManagementService::Client.new do |config|
2113
+ # config.timeout = 10_000
2114
+ # config.rpcs.list_key_rings.timeout = 20_000
2115
+ # end
2116
+ #
2117
+ # @!attribute [rw] endpoint
2118
+ # The hostname or hostname:port of the service endpoint.
2119
+ # Defaults to `"cloudkms.googleapis.com"`.
2120
+ # @return [String]
2121
+ # @!attribute [rw] credentials
2122
+ # Credentials to send with calls. You may provide any of the following types:
2123
+ # * (`String`) The path to a service account key file in JSON format
2124
+ # * (`Hash`) A service account key as a Hash
2125
+ # * (`Google::Auth::Credentials`) A googleauth credentials object
2126
+ # (see the [googleauth docs](https://googleapis.dev/ruby/googleauth/latest/index.html))
2127
+ # * (`Signet::OAuth2::Client`) A signet oauth2 client object
2128
+ # (see the [signet docs](https://googleapis.dev/ruby/signet/latest/Signet/OAuth2/Client.html))
2129
+ # * (`GRPC::Core::Channel`) a gRPC channel with included credentials
2130
+ # * (`GRPC::Core::ChannelCredentials`) a gRPC credentails object
2131
+ # * (`nil`) indicating no credentials
2132
+ # @return [Object]
2133
+ # @!attribute [rw] scope
2134
+ # The OAuth scopes
2135
+ # @return [Array<String>]
2136
+ # @!attribute [rw] lib_name
2137
+ # The library name as recorded in instrumentation and logging
2138
+ # @return [String]
2139
+ # @!attribute [rw] lib_version
2140
+ # The library version as recorded in instrumentation and logging
2141
+ # @return [String]
2142
+ # @!attribute [rw] channel_args
2143
+ # Extra parameters passed to the gRPC channel. Note: this is ignored if a
2144
+ # `GRPC::Core::Channel` object is provided as the credential.
2145
+ # @return [Hash]
2146
+ # @!attribute [rw] interceptors
2147
+ # An array of interceptors that are run before calls are executed.
2148
+ # @return [Array<GRPC::ClientInterceptor>]
2149
+ # @!attribute [rw] timeout
2150
+ # The call timeout in milliseconds.
2151
+ # @return [Numeric]
2152
+ # @!attribute [rw] metadata
2153
+ # Additional gRPC headers to be sent with the call.
2154
+ # @return [Hash{Symbol=>String}]
2155
+ # @!attribute [rw] retry_policy
2156
+ # The retry policy. The value is a hash with the following keys:
2157
+ # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
2158
+ # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
2159
+ # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
2160
+ # * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
2161
+ # trigger a retry.
2162
+ # @return [Hash]
2163
+ #
2164
+ class Configuration
2165
+ extend Gapic::Config
2166
+
2167
+ config_attr :endpoint, "cloudkms.googleapis.com", String
2168
+ config_attr :credentials, nil do |value|
2169
+ allowed = [::String, ::Hash, ::Proc, ::Google::Auth::Credentials, ::Signet::OAuth2::Client, nil]
2170
+ allowed += [::GRPC::Core::Channel, ::GRPC::Core::ChannelCredentials] if defined? ::GRPC
2171
+ allowed.any? { |klass| klass === value }
2172
+ end
2173
+ config_attr :scope, nil, String, Array, nil
2174
+ config_attr :lib_name, nil, String, nil
2175
+ config_attr :lib_version, nil, String, nil
2176
+ config_attr(:channel_args, { "grpc.service_config_disable_resolution"=>1 }, Hash, nil)
2177
+ config_attr :interceptors, nil, Array, nil
2178
+ config_attr :timeout, nil, Numeric, nil
2179
+ config_attr :metadata, nil, Hash, nil
2180
+ config_attr :retry_policy, nil, Hash, Proc, nil
2181
+
2182
+ # @private
2183
+ def initialize parent_config = nil
2184
+ @parent_config = parent_config unless parent_config.nil?
2185
+
2186
+ yield self if block_given?
2187
+ end
2188
+
2189
+ ##
2190
+ # Configurations for individual RPCs
2191
+ # @return [Rpcs]
2192
+ #
2193
+ def rpcs
2194
+ @rpcs ||= begin
2195
+ parent_rpcs = nil
2196
+ parent_rpcs = @parent_config.rpcs if @parent_config&.respond_to? :rpcs
2197
+ Rpcs.new parent_rpcs
2198
+ end
2199
+ end
2200
+
2201
+ ##
2202
+ # Configuration RPC class for the KeyManagementService API.
2203
+ #
2204
+ # Includes fields providing the configuration for each RPC in this service.
2205
+ # Each configuration object is of type `Gapic::Config::Method` and includes
2206
+ # the following configuration fields:
2207
+ #
2208
+ # * `timeout` (*type:* `Numeric`) - The call timeout in milliseconds
2209
+ # * `metadata` (*type:* `Hash{Symbol=>String}`) - Additional gRPC headers
2210
+ # * `retry_policy (*type:* `Hash`) - The retry policy. The policy fields
2211
+ # include the following keys:
2212
+ # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
2213
+ # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
2214
+ # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
2215
+ # * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
2216
+ # trigger a retry.
2217
+ #
2218
+ class Rpcs
2219
+ ##
2220
+ # RPC-specific configuration for `list_key_rings`
2221
+ # @return [Gapic::Config::Method]
2222
+ #
2223
+ attr_reader :list_key_rings
2224
+ ##
2225
+ # RPC-specific configuration for `list_crypto_keys`
2226
+ # @return [Gapic::Config::Method]
2227
+ #
2228
+ attr_reader :list_crypto_keys
2229
+ ##
2230
+ # RPC-specific configuration for `list_crypto_key_versions`
2231
+ # @return [Gapic::Config::Method]
2232
+ #
2233
+ attr_reader :list_crypto_key_versions
2234
+ ##
2235
+ # RPC-specific configuration for `list_import_jobs`
2236
+ # @return [Gapic::Config::Method]
2237
+ #
2238
+ attr_reader :list_import_jobs
2239
+ ##
2240
+ # RPC-specific configuration for `get_key_ring`
2241
+ # @return [Gapic::Config::Method]
2242
+ #
2243
+ attr_reader :get_key_ring
2244
+ ##
2245
+ # RPC-specific configuration for `get_crypto_key`
2246
+ # @return [Gapic::Config::Method]
2247
+ #
2248
+ attr_reader :get_crypto_key
2249
+ ##
2250
+ # RPC-specific configuration for `get_crypto_key_version`
2251
+ # @return [Gapic::Config::Method]
2252
+ #
2253
+ attr_reader :get_crypto_key_version
2254
+ ##
2255
+ # RPC-specific configuration for `get_public_key`
2256
+ # @return [Gapic::Config::Method]
2257
+ #
2258
+ attr_reader :get_public_key
2259
+ ##
2260
+ # RPC-specific configuration for `get_import_job`
2261
+ # @return [Gapic::Config::Method]
2262
+ #
2263
+ attr_reader :get_import_job
2264
+ ##
2265
+ # RPC-specific configuration for `create_key_ring`
2266
+ # @return [Gapic::Config::Method]
2267
+ #
2268
+ attr_reader :create_key_ring
2269
+ ##
2270
+ # RPC-specific configuration for `create_crypto_key`
2271
+ # @return [Gapic::Config::Method]
2272
+ #
2273
+ attr_reader :create_crypto_key
2274
+ ##
2275
+ # RPC-specific configuration for `create_crypto_key_version`
2276
+ # @return [Gapic::Config::Method]
2277
+ #
2278
+ attr_reader :create_crypto_key_version
2279
+ ##
2280
+ # RPC-specific configuration for `import_crypto_key_version`
2281
+ # @return [Gapic::Config::Method]
2282
+ #
2283
+ attr_reader :import_crypto_key_version
2284
+ ##
2285
+ # RPC-specific configuration for `create_import_job`
2286
+ # @return [Gapic::Config::Method]
2287
+ #
2288
+ attr_reader :create_import_job
2289
+ ##
2290
+ # RPC-specific configuration for `update_crypto_key`
2291
+ # @return [Gapic::Config::Method]
2292
+ #
2293
+ attr_reader :update_crypto_key
2294
+ ##
2295
+ # RPC-specific configuration for `update_crypto_key_version`
2296
+ # @return [Gapic::Config::Method]
2297
+ #
2298
+ attr_reader :update_crypto_key_version
2299
+ ##
2300
+ # RPC-specific configuration for `encrypt`
2301
+ # @return [Gapic::Config::Method]
2302
+ #
2303
+ attr_reader :encrypt
2304
+ ##
2305
+ # RPC-specific configuration for `decrypt`
2306
+ # @return [Gapic::Config::Method]
2307
+ #
2308
+ attr_reader :decrypt
2309
+ ##
2310
+ # RPC-specific configuration for `asymmetric_sign`
2311
+ # @return [Gapic::Config::Method]
2312
+ #
2313
+ attr_reader :asymmetric_sign
2314
+ ##
2315
+ # RPC-specific configuration for `asymmetric_decrypt`
2316
+ # @return [Gapic::Config::Method]
2317
+ #
2318
+ attr_reader :asymmetric_decrypt
2319
+ ##
2320
+ # RPC-specific configuration for `update_crypto_key_primary_version`
2321
+ # @return [Gapic::Config::Method]
2322
+ #
2323
+ attr_reader :update_crypto_key_primary_version
2324
+ ##
2325
+ # RPC-specific configuration for `destroy_crypto_key_version`
2326
+ # @return [Gapic::Config::Method]
2327
+ #
2328
+ attr_reader :destroy_crypto_key_version
2329
+ ##
2330
+ # RPC-specific configuration for `restore_crypto_key_version`
2331
+ # @return [Gapic::Config::Method]
2332
+ #
2333
+ attr_reader :restore_crypto_key_version
2334
+
2335
+ # @private
2336
+ def initialize parent_rpcs = nil
2337
+ list_key_rings_config = parent_rpcs&.list_key_rings if parent_rpcs&.respond_to? :list_key_rings
2338
+ @list_key_rings = Gapic::Config::Method.new list_key_rings_config
2339
+ list_crypto_keys_config = parent_rpcs&.list_crypto_keys if parent_rpcs&.respond_to? :list_crypto_keys
2340
+ @list_crypto_keys = Gapic::Config::Method.new list_crypto_keys_config
2341
+ list_crypto_key_versions_config = parent_rpcs&.list_crypto_key_versions if parent_rpcs&.respond_to? :list_crypto_key_versions
2342
+ @list_crypto_key_versions = Gapic::Config::Method.new list_crypto_key_versions_config
2343
+ list_import_jobs_config = parent_rpcs&.list_import_jobs if parent_rpcs&.respond_to? :list_import_jobs
2344
+ @list_import_jobs = Gapic::Config::Method.new list_import_jobs_config
2345
+ get_key_ring_config = parent_rpcs&.get_key_ring if parent_rpcs&.respond_to? :get_key_ring
2346
+ @get_key_ring = Gapic::Config::Method.new get_key_ring_config
2347
+ get_crypto_key_config = parent_rpcs&.get_crypto_key if parent_rpcs&.respond_to? :get_crypto_key
2348
+ @get_crypto_key = Gapic::Config::Method.new get_crypto_key_config
2349
+ get_crypto_key_version_config = parent_rpcs&.get_crypto_key_version if parent_rpcs&.respond_to? :get_crypto_key_version
2350
+ @get_crypto_key_version = Gapic::Config::Method.new get_crypto_key_version_config
2351
+ get_public_key_config = parent_rpcs&.get_public_key if parent_rpcs&.respond_to? :get_public_key
2352
+ @get_public_key = Gapic::Config::Method.new get_public_key_config
2353
+ get_import_job_config = parent_rpcs&.get_import_job if parent_rpcs&.respond_to? :get_import_job
2354
+ @get_import_job = Gapic::Config::Method.new get_import_job_config
2355
+ create_key_ring_config = parent_rpcs&.create_key_ring if parent_rpcs&.respond_to? :create_key_ring
2356
+ @create_key_ring = Gapic::Config::Method.new create_key_ring_config
2357
+ create_crypto_key_config = parent_rpcs&.create_crypto_key if parent_rpcs&.respond_to? :create_crypto_key
2358
+ @create_crypto_key = Gapic::Config::Method.new create_crypto_key_config
2359
+ create_crypto_key_version_config = parent_rpcs&.create_crypto_key_version if parent_rpcs&.respond_to? :create_crypto_key_version
2360
+ @create_crypto_key_version = Gapic::Config::Method.new create_crypto_key_version_config
2361
+ import_crypto_key_version_config = parent_rpcs&.import_crypto_key_version if parent_rpcs&.respond_to? :import_crypto_key_version
2362
+ @import_crypto_key_version = Gapic::Config::Method.new import_crypto_key_version_config
2363
+ create_import_job_config = parent_rpcs&.create_import_job if parent_rpcs&.respond_to? :create_import_job
2364
+ @create_import_job = Gapic::Config::Method.new create_import_job_config
2365
+ update_crypto_key_config = parent_rpcs&.update_crypto_key if parent_rpcs&.respond_to? :update_crypto_key
2366
+ @update_crypto_key = Gapic::Config::Method.new update_crypto_key_config
2367
+ update_crypto_key_version_config = parent_rpcs&.update_crypto_key_version if parent_rpcs&.respond_to? :update_crypto_key_version
2368
+ @update_crypto_key_version = Gapic::Config::Method.new update_crypto_key_version_config
2369
+ encrypt_config = parent_rpcs&.encrypt if parent_rpcs&.respond_to? :encrypt
2370
+ @encrypt = Gapic::Config::Method.new encrypt_config
2371
+ decrypt_config = parent_rpcs&.decrypt if parent_rpcs&.respond_to? :decrypt
2372
+ @decrypt = Gapic::Config::Method.new decrypt_config
2373
+ asymmetric_sign_config = parent_rpcs&.asymmetric_sign if parent_rpcs&.respond_to? :asymmetric_sign
2374
+ @asymmetric_sign = Gapic::Config::Method.new asymmetric_sign_config
2375
+ asymmetric_decrypt_config = parent_rpcs&.asymmetric_decrypt if parent_rpcs&.respond_to? :asymmetric_decrypt
2376
+ @asymmetric_decrypt = Gapic::Config::Method.new asymmetric_decrypt_config
2377
+ update_crypto_key_primary_version_config = parent_rpcs&.update_crypto_key_primary_version if parent_rpcs&.respond_to? :update_crypto_key_primary_version
2378
+ @update_crypto_key_primary_version = Gapic::Config::Method.new update_crypto_key_primary_version_config
2379
+ destroy_crypto_key_version_config = parent_rpcs&.destroy_crypto_key_version if parent_rpcs&.respond_to? :destroy_crypto_key_version
2380
+ @destroy_crypto_key_version = Gapic::Config::Method.new destroy_crypto_key_version_config
2381
+ restore_crypto_key_version_config = parent_rpcs&.restore_crypto_key_version if parent_rpcs&.respond_to? :restore_crypto_key_version
2382
+ @restore_crypto_key_version = Gapic::Config::Method.new restore_crypto_key_version_config
2383
+
2384
+ yield self if block_given?
2385
+ end
2386
+ end
2387
+ end
2388
+ end
2389
+ end
2390
+ end
2391
+ end
2392
+ end
2393
+ end