google-cloud-kms 1.4.0 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,19 +0,0 @@
1
- # Copyright 2019 Google LLC
2
- #
3
- # Licensed under the Apache License, Version 2.0 (the "License");
4
- # you may not use this file except in compliance with the License.
5
- # You may obtain a copy of the License at
6
- #
7
- # https://www.apache.org/licenses/LICENSE-2.0
8
- #
9
- # Unless required by applicable law or agreed to in writing, software
10
- # distributed under the License is distributed on an "AS IS" BASIS,
11
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- # See the License for the specific language governing permissions and
13
- # limitations under the License.
14
-
15
-
16
- module Google
17
- module Type
18
- end
19
- end
@@ -1,80 +0,0 @@
1
- # Copyright 2018 Google LLC
2
- #
3
- # Licensed under the Apache License, Version 2.0 (the "License");
4
- # you may not use this file except in compliance with the License.
5
- # You may obtain a copy of the License at
6
- #
7
- # https://www.apache.org/licenses/LICENSE-2.0
8
- #
9
- # Unless required by applicable law or agreed to in writing, software
10
- # distributed under the License is distributed on an "AS IS" BASIS,
11
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- # See the License for the specific language governing permissions and
13
- # # limitations under the License.
14
- module Google
15
- module Cloud
16
- module Kms
17
- module V1
18
- class KeyManagementServiceClient
19
- # Alias for Google::Cloud::Kms::V1::KeyManagementServiceClient.crypto_key_path.
20
- # @param project [String]
21
- # @param location [String]
22
- # @param key_ring [String]
23
- # @param crypto_key [String]
24
- # @return [String]
25
- def crypto_key_path project, location, key_ring, crypto_key
26
- self.class.crypto_key_path project, location, key_ring, crypto_key
27
- end
28
-
29
- # Alias for Google::Cloud::Kms::V1::KeyManagementServiceClient.crypto_key_path_path.
30
- # @param project [String]
31
- # @param location [String]
32
- # @param key_ring [String]
33
- # @param crypto_key_path [String]
34
- # @return [String]
35
- def crypto_key_path_path project, location, key_ring, crypto_key_path
36
- self.class.crypto_key_path_path project, location, key_ring, crypto_key_path
37
- end
38
-
39
- # Alias for Google::Cloud::Kms::V1::KeyManagementServiceClient.crypto_key_version_path.
40
- # @param project [String]
41
- # @param location [String]
42
- # @param key_ring [String]
43
- # @param crypto_key [String]
44
- # @param crypto_key_version [String]
45
- # @return [String]
46
- def crypto_key_version_path project, location, key_ring, crypto_key, crypto_key_version
47
- self.class.crypto_key_version_path project, location, key_ring, crypto_key, crypto_key_version
48
- end
49
-
50
- # Alias for Google::Cloud::Kms::V1::KeyManagementServiceClient.import_job_path.
51
- # @param project [String]
52
- # @param location [String]
53
- # @param key_ring [String]
54
- # @param import_job [String]
55
- # @return [String]
56
- def import_job_path project, location, key_ring, import_job
57
- self.class.import_job_path project, location, key_ring, import_job
58
- end
59
-
60
- # Alias for Google::Cloud::Kms::V1::KeyManagementServiceClient.key_ring_path.
61
- # @param project [String]
62
- # @param location [String]
63
- # @param key_ring [String]
64
- # @return [String]
65
- def key_ring_path project, location, key_ring
66
- self.class.key_ring_path project, location, key_ring
67
- end
68
-
69
- # Alias for Google::Cloud::Kms::V1::KeyManagementServiceClient.location_path.
70
- # @param project [String]
71
- # @param location [String]
72
- # @return [String]
73
- def location_path project, location
74
- self.class.location_path project, location
75
- end
76
- end
77
- end
78
- end
79
- end
80
- end
@@ -1,1810 +0,0 @@
1
- # Copyright 2019 Google LLC
2
- #
3
- # Licensed under the Apache License, Version 2.0 (the "License");
4
- # you may not use this file except in compliance with the License.
5
- # You may obtain a copy of the License at
6
- #
7
- # https://www.apache.org/licenses/LICENSE-2.0
8
- #
9
- # Unless required by applicable law or agreed to in writing, software
10
- # distributed under the License is distributed on an "AS IS" BASIS,
11
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- # See the License for the specific language governing permissions and
13
- # limitations under the License.
14
- #
15
- # EDITING INSTRUCTIONS
16
- # This file was generated from the file
17
- # https://github.com/googleapis/googleapis/blob/master/google/cloud/kms/v1/service.proto,
18
- # and updates to that file get reflected here through a refresh process.
19
- # For the short term, the refresh process will only be runnable by Google
20
- # engineers.
21
-
22
-
23
- require "json"
24
- require "pathname"
25
-
26
- require "google/gax"
27
-
28
- require "google/cloud/kms/v1/service_pb"
29
- require "google/iam/v1/iam_policy_pb"
30
- require "google/cloud/kms/v1/credentials"
31
- require "google/cloud/kms/version"
32
-
33
- module Google
34
- module Cloud
35
- module Kms
36
- module V1
37
- # Google Cloud Key Management Service
38
- #
39
- # Manages cryptographic keys and operations using those keys. Implements a REST
40
- # model with the following objects:
41
- #
42
- # * {Google::Cloud::Kms::V1::KeyRing KeyRing}
43
- # * {Google::Cloud::Kms::V1::CryptoKey CryptoKey}
44
- # * {Google::Cloud::Kms::V1::CryptoKeyVersion CryptoKeyVersion}
45
- # * {Google::Cloud::Kms::V1::ImportJob ImportJob}
46
- #
47
- # If you are using manual gRPC libraries, see
48
- # [Using gRPC with Cloud KMS](https://cloud.google.com/kms/docs/grpc).
49
- #
50
- # @!attribute [r] key_management_service_stub
51
- # @return [Google::Cloud::Kms::V1::KeyManagementService::Stub]
52
- # @!attribute [r] iam_policy_stub
53
- # @return [Google::Iam::V1::IAMPolicy::Stub]
54
- class KeyManagementServiceClient
55
- # @private
56
- attr_reader :key_management_service_stub, :iam_policy_stub
57
-
58
- # The default address of the service.
59
- SERVICE_ADDRESS = "cloudkms.googleapis.com".freeze
60
-
61
- # The default port of the service.
62
- DEFAULT_SERVICE_PORT = 443
63
-
64
- # The default set of gRPC interceptors.
65
- GRPC_INTERCEPTORS = []
66
-
67
- DEFAULT_TIMEOUT = 30
68
-
69
- PAGE_DESCRIPTORS = {
70
- "list_key_rings" => Google::Gax::PageDescriptor.new(
71
- "page_token",
72
- "next_page_token",
73
- "key_rings"),
74
- "list_import_jobs" => Google::Gax::PageDescriptor.new(
75
- "page_token",
76
- "next_page_token",
77
- "import_jobs"),
78
- "list_crypto_keys" => Google::Gax::PageDescriptor.new(
79
- "page_token",
80
- "next_page_token",
81
- "crypto_keys"),
82
- "list_crypto_key_versions" => Google::Gax::PageDescriptor.new(
83
- "page_token",
84
- "next_page_token",
85
- "crypto_key_versions")
86
- }.freeze
87
-
88
- private_constant :PAGE_DESCRIPTORS
89
-
90
- # The scopes needed to make gRPC calls to all of the methods defined in
91
- # this service.
92
- ALL_SCOPES = [
93
- "https://www.googleapis.com/auth/cloud-platform",
94
- "https://www.googleapis.com/auth/cloudkms"
95
- ].freeze
96
-
97
-
98
- CRYPTO_KEY_PATH_TEMPLATE = Google::Gax::PathTemplate.new(
99
- "projects/{project}/locations/{location}/keyRings/{key_ring}/cryptoKeys/{crypto_key}"
100
- )
101
-
102
- private_constant :CRYPTO_KEY_PATH_TEMPLATE
103
-
104
- CRYPTO_KEY_PATH_PATH_TEMPLATE = Google::Gax::PathTemplate.new(
105
- "projects/{project}/locations/{location}/keyRings/{key_ring}/cryptoKeys/{crypto_key_path=**}"
106
- )
107
-
108
- private_constant :CRYPTO_KEY_PATH_PATH_TEMPLATE
109
-
110
- CRYPTO_KEY_VERSION_PATH_TEMPLATE = Google::Gax::PathTemplate.new(
111
- "projects/{project}/locations/{location}/keyRings/{key_ring}/cryptoKeys/{crypto_key}/cryptoKeyVersions/{crypto_key_version}"
112
- )
113
-
114
- private_constant :CRYPTO_KEY_VERSION_PATH_TEMPLATE
115
-
116
- IMPORT_JOB_PATH_TEMPLATE = Google::Gax::PathTemplate.new(
117
- "projects/{project}/locations/{location}/keyRings/{key_ring}/importJobs/{import_job}"
118
- )
119
-
120
- private_constant :IMPORT_JOB_PATH_TEMPLATE
121
-
122
- KEY_RING_PATH_TEMPLATE = Google::Gax::PathTemplate.new(
123
- "projects/{project}/locations/{location}/keyRings/{key_ring}"
124
- )
125
-
126
- private_constant :KEY_RING_PATH_TEMPLATE
127
-
128
- LOCATION_PATH_TEMPLATE = Google::Gax::PathTemplate.new(
129
- "projects/{project}/locations/{location}"
130
- )
131
-
132
- private_constant :LOCATION_PATH_TEMPLATE
133
-
134
- # Returns a fully-qualified crypto_key resource name string.
135
- # @param project [String]
136
- # @param location [String]
137
- # @param key_ring [String]
138
- # @param crypto_key [String]
139
- # @return [String]
140
- def self.crypto_key_path project, location, key_ring, crypto_key
141
- CRYPTO_KEY_PATH_TEMPLATE.render(
142
- :"project" => project,
143
- :"location" => location,
144
- :"key_ring" => key_ring,
145
- :"crypto_key" => crypto_key
146
- )
147
- end
148
-
149
- # Returns a fully-qualified crypto_key_path resource name string.
150
- # @param project [String]
151
- # @param location [String]
152
- # @param key_ring [String]
153
- # @param crypto_key_path [String]
154
- # @return [String]
155
- def self.crypto_key_path_path project, location, key_ring, crypto_key_path
156
- CRYPTO_KEY_PATH_PATH_TEMPLATE.render(
157
- :"project" => project,
158
- :"location" => location,
159
- :"key_ring" => key_ring,
160
- :"crypto_key_path" => crypto_key_path
161
- )
162
- end
163
-
164
- # Returns a fully-qualified crypto_key_version resource name string.
165
- # @param project [String]
166
- # @param location [String]
167
- # @param key_ring [String]
168
- # @param crypto_key [String]
169
- # @param crypto_key_version [String]
170
- # @return [String]
171
- def self.crypto_key_version_path project, location, key_ring, crypto_key, crypto_key_version
172
- CRYPTO_KEY_VERSION_PATH_TEMPLATE.render(
173
- :"project" => project,
174
- :"location" => location,
175
- :"key_ring" => key_ring,
176
- :"crypto_key" => crypto_key,
177
- :"crypto_key_version" => crypto_key_version
178
- )
179
- end
180
-
181
- # Returns a fully-qualified import_job resource name string.
182
- # @param project [String]
183
- # @param location [String]
184
- # @param key_ring [String]
185
- # @param import_job [String]
186
- # @return [String]
187
- def self.import_job_path project, location, key_ring, import_job
188
- IMPORT_JOB_PATH_TEMPLATE.render(
189
- :"project" => project,
190
- :"location" => location,
191
- :"key_ring" => key_ring,
192
- :"import_job" => import_job
193
- )
194
- end
195
-
196
- # Returns a fully-qualified key_ring resource name string.
197
- # @param project [String]
198
- # @param location [String]
199
- # @param key_ring [String]
200
- # @return [String]
201
- def self.key_ring_path project, location, key_ring
202
- KEY_RING_PATH_TEMPLATE.render(
203
- :"project" => project,
204
- :"location" => location,
205
- :"key_ring" => key_ring
206
- )
207
- end
208
-
209
- # Returns a fully-qualified location resource name string.
210
- # @param project [String]
211
- # @param location [String]
212
- # @return [String]
213
- def self.location_path project, location
214
- LOCATION_PATH_TEMPLATE.render(
215
- :"project" => project,
216
- :"location" => location
217
- )
218
- end
219
-
220
- # @param credentials [Google::Auth::Credentials, String, Hash, GRPC::Core::Channel, GRPC::Core::ChannelCredentials, Proc]
221
- # Provides the means for authenticating requests made by the client. This parameter can
222
- # be many types.
223
- # A `Google::Auth::Credentials` uses a the properties of its represented keyfile for
224
- # authenticating requests made by this client.
225
- # A `String` will be treated as the path to the keyfile to be used for the construction of
226
- # credentials for this client.
227
- # A `Hash` will be treated as the contents of a keyfile to be used for the construction of
228
- # credentials for this client.
229
- # A `GRPC::Core::Channel` will be used to make calls through.
230
- # A `GRPC::Core::ChannelCredentials` for the setting up the RPC client. The channel credentials
231
- # should already be composed with a `GRPC::Core::CallCredentials` object.
232
- # A `Proc` will be used as an updater_proc for the Grpc channel. The proc transforms the
233
- # metadata for requests, generally, to give OAuth credentials.
234
- # @param scopes [Array<String>]
235
- # The OAuth scopes for this service. This parameter is ignored if
236
- # an updater_proc is supplied.
237
- # @param client_config [Hash]
238
- # A Hash for call options for each method. See
239
- # Google::Gax#construct_settings for the structure of
240
- # this data. Falls back to the default config if not specified
241
- # or the specified config is missing data points.
242
- # @param timeout [Numeric]
243
- # The default timeout, in seconds, for calls made through this client.
244
- # @param metadata [Hash]
245
- # Default metadata to be sent with each request. This can be overridden on a per call basis.
246
- # @param service_address [String]
247
- # Override for the service hostname, or `nil` to leave as the default.
248
- # @param service_port [Integer]
249
- # Override for the service port, or `nil` to leave as the default.
250
- # @param exception_transformer [Proc]
251
- # An optional proc that intercepts any exceptions raised during an API call to inject
252
- # custom error handling.
253
- def initialize \
254
- credentials: nil,
255
- scopes: ALL_SCOPES,
256
- client_config: {},
257
- timeout: DEFAULT_TIMEOUT,
258
- metadata: nil,
259
- service_address: nil,
260
- service_port: nil,
261
- exception_transformer: nil,
262
- lib_name: nil,
263
- lib_version: ""
264
- # These require statements are intentionally placed here to initialize
265
- # the gRPC module only when it's required.
266
- # See https://github.com/googleapis/toolkit/issues/446
267
- require "google/gax/grpc"
268
- require "google/cloud/kms/v1/service_services_pb"
269
- require "google/iam/v1/iam_policy_services_pb"
270
-
271
- credentials ||= Google::Cloud::Kms::V1::Credentials.default
272
-
273
- if credentials.is_a?(String) || credentials.is_a?(Hash)
274
- updater_proc = Google::Cloud::Kms::V1::Credentials.new(credentials).updater_proc
275
- end
276
- if credentials.is_a?(GRPC::Core::Channel)
277
- channel = credentials
278
- end
279
- if credentials.is_a?(GRPC::Core::ChannelCredentials)
280
- chan_creds = credentials
281
- end
282
- if credentials.is_a?(Proc)
283
- updater_proc = credentials
284
- end
285
- if credentials.is_a?(Google::Auth::Credentials)
286
- updater_proc = credentials.updater_proc
287
- end
288
-
289
- package_version = Google::Cloud::Kms::VERSION
290
-
291
- google_api_client = "gl-ruby/#{RUBY_VERSION}"
292
- google_api_client << " #{lib_name}/#{lib_version}" if lib_name
293
- google_api_client << " gapic/#{package_version} gax/#{Google::Gax::VERSION}"
294
- google_api_client << " grpc/#{GRPC::VERSION}"
295
- google_api_client.freeze
296
-
297
- headers = { :"x-goog-api-client" => google_api_client }
298
- headers.merge!(metadata) unless metadata.nil?
299
- client_config_file = Pathname.new(__dir__).join(
300
- "key_management_service_client_config.json"
301
- )
302
- defaults = client_config_file.open do |f|
303
- Google::Gax.construct_settings(
304
- "google.cloud.kms.v1.KeyManagementService",
305
- JSON.parse(f.read),
306
- client_config,
307
- Google::Gax::Grpc::STATUS_CODE_NAMES,
308
- timeout,
309
- page_descriptors: PAGE_DESCRIPTORS,
310
- errors: Google::Gax::Grpc::API_ERRORS,
311
- metadata: headers
312
- )
313
- end
314
-
315
- # Allow overriding the service path/port in subclasses.
316
- service_path = service_address || self.class::SERVICE_ADDRESS
317
- port = service_port || self.class::DEFAULT_SERVICE_PORT
318
- interceptors = self.class::GRPC_INTERCEPTORS
319
- @key_management_service_stub = Google::Gax::Grpc.create_stub(
320
- service_path,
321
- port,
322
- chan_creds: chan_creds,
323
- channel: channel,
324
- updater_proc: updater_proc,
325
- scopes: scopes,
326
- interceptors: interceptors,
327
- &Google::Cloud::Kms::V1::KeyManagementService::Stub.method(:new)
328
- )
329
- @iam_policy_stub = Google::Gax::Grpc.create_stub(
330
- service_path,
331
- port,
332
- chan_creds: chan_creds,
333
- channel: channel,
334
- updater_proc: updater_proc,
335
- scopes: scopes,
336
- interceptors: interceptors,
337
- &Google::Iam::V1::IAMPolicy::Stub.method(:new)
338
- )
339
-
340
- @list_key_rings = Google::Gax.create_api_call(
341
- @key_management_service_stub.method(:list_key_rings),
342
- defaults["list_key_rings"],
343
- exception_transformer: exception_transformer,
344
- params_extractor: proc do |request|
345
- {'parent' => request.parent}
346
- end
347
- )
348
- @list_import_jobs = Google::Gax.create_api_call(
349
- @key_management_service_stub.method(:list_import_jobs),
350
- defaults["list_import_jobs"],
351
- exception_transformer: exception_transformer,
352
- params_extractor: proc do |request|
353
- {'parent' => request.parent}
354
- end
355
- )
356
- @list_crypto_keys = Google::Gax.create_api_call(
357
- @key_management_service_stub.method(:list_crypto_keys),
358
- defaults["list_crypto_keys"],
359
- exception_transformer: exception_transformer,
360
- params_extractor: proc do |request|
361
- {'parent' => request.parent}
362
- end
363
- )
364
- @list_crypto_key_versions = Google::Gax.create_api_call(
365
- @key_management_service_stub.method(:list_crypto_key_versions),
366
- defaults["list_crypto_key_versions"],
367
- exception_transformer: exception_transformer,
368
- params_extractor: proc do |request|
369
- {'parent' => request.parent}
370
- end
371
- )
372
- @get_key_ring = Google::Gax.create_api_call(
373
- @key_management_service_stub.method(:get_key_ring),
374
- defaults["get_key_ring"],
375
- exception_transformer: exception_transformer,
376
- params_extractor: proc do |request|
377
- {'name' => request.name}
378
- end
379
- )
380
- @get_import_job = Google::Gax.create_api_call(
381
- @key_management_service_stub.method(:get_import_job),
382
- defaults["get_import_job"],
383
- exception_transformer: exception_transformer,
384
- params_extractor: proc do |request|
385
- {'name' => request.name}
386
- end
387
- )
388
- @get_crypto_key = Google::Gax.create_api_call(
389
- @key_management_service_stub.method(:get_crypto_key),
390
- defaults["get_crypto_key"],
391
- exception_transformer: exception_transformer,
392
- params_extractor: proc do |request|
393
- {'name' => request.name}
394
- end
395
- )
396
- @get_crypto_key_version = Google::Gax.create_api_call(
397
- @key_management_service_stub.method(:get_crypto_key_version),
398
- defaults["get_crypto_key_version"],
399
- exception_transformer: exception_transformer,
400
- params_extractor: proc do |request|
401
- {'name' => request.name}
402
- end
403
- )
404
- @create_key_ring = Google::Gax.create_api_call(
405
- @key_management_service_stub.method(:create_key_ring),
406
- defaults["create_key_ring"],
407
- exception_transformer: exception_transformer,
408
- params_extractor: proc do |request|
409
- {'parent' => request.parent}
410
- end
411
- )
412
- @create_import_job = Google::Gax.create_api_call(
413
- @key_management_service_stub.method(:create_import_job),
414
- defaults["create_import_job"],
415
- exception_transformer: exception_transformer,
416
- params_extractor: proc do |request|
417
- {'parent' => request.parent}
418
- end
419
- )
420
- @create_crypto_key = Google::Gax.create_api_call(
421
- @key_management_service_stub.method(:create_crypto_key),
422
- defaults["create_crypto_key"],
423
- exception_transformer: exception_transformer,
424
- params_extractor: proc do |request|
425
- {'parent' => request.parent}
426
- end
427
- )
428
- @create_crypto_key_version = Google::Gax.create_api_call(
429
- @key_management_service_stub.method(:create_crypto_key_version),
430
- defaults["create_crypto_key_version"],
431
- exception_transformer: exception_transformer,
432
- params_extractor: proc do |request|
433
- {'parent' => request.parent}
434
- end
435
- )
436
- @import_crypto_key_version = Google::Gax.create_api_call(
437
- @key_management_service_stub.method(:import_crypto_key_version),
438
- defaults["import_crypto_key_version"],
439
- exception_transformer: exception_transformer,
440
- params_extractor: proc do |request|
441
- {'parent' => request.parent}
442
- end
443
- )
444
- @update_crypto_key = Google::Gax.create_api_call(
445
- @key_management_service_stub.method(:update_crypto_key),
446
- defaults["update_crypto_key"],
447
- exception_transformer: exception_transformer,
448
- params_extractor: proc do |request|
449
- {'crypto_key.name' => request.crypto_key.name}
450
- end
451
- )
452
- @update_crypto_key_version = Google::Gax.create_api_call(
453
- @key_management_service_stub.method(:update_crypto_key_version),
454
- defaults["update_crypto_key_version"],
455
- exception_transformer: exception_transformer,
456
- params_extractor: proc do |request|
457
- {'crypto_key_version.name' => request.crypto_key_version.name}
458
- end
459
- )
460
- @encrypt = Google::Gax.create_api_call(
461
- @key_management_service_stub.method(:encrypt),
462
- defaults["encrypt"],
463
- exception_transformer: exception_transformer,
464
- params_extractor: proc do |request|
465
- {'name' => request.name}
466
- end
467
- )
468
- @decrypt = Google::Gax.create_api_call(
469
- @key_management_service_stub.method(:decrypt),
470
- defaults["decrypt"],
471
- exception_transformer: exception_transformer,
472
- params_extractor: proc do |request|
473
- {'name' => request.name}
474
- end
475
- )
476
- @update_crypto_key_primary_version = Google::Gax.create_api_call(
477
- @key_management_service_stub.method(:update_crypto_key_primary_version),
478
- defaults["update_crypto_key_primary_version"],
479
- exception_transformer: exception_transformer,
480
- params_extractor: proc do |request|
481
- {'name' => request.name}
482
- end
483
- )
484
- @destroy_crypto_key_version = Google::Gax.create_api_call(
485
- @key_management_service_stub.method(:destroy_crypto_key_version),
486
- defaults["destroy_crypto_key_version"],
487
- exception_transformer: exception_transformer,
488
- params_extractor: proc do |request|
489
- {'name' => request.name}
490
- end
491
- )
492
- @restore_crypto_key_version = Google::Gax.create_api_call(
493
- @key_management_service_stub.method(:restore_crypto_key_version),
494
- defaults["restore_crypto_key_version"],
495
- exception_transformer: exception_transformer,
496
- params_extractor: proc do |request|
497
- {'name' => request.name}
498
- end
499
- )
500
- @get_public_key = Google::Gax.create_api_call(
501
- @key_management_service_stub.method(:get_public_key),
502
- defaults["get_public_key"],
503
- exception_transformer: exception_transformer,
504
- params_extractor: proc do |request|
505
- {'name' => request.name}
506
- end
507
- )
508
- @asymmetric_decrypt = Google::Gax.create_api_call(
509
- @key_management_service_stub.method(:asymmetric_decrypt),
510
- defaults["asymmetric_decrypt"],
511
- exception_transformer: exception_transformer,
512
- params_extractor: proc do |request|
513
- {'name' => request.name}
514
- end
515
- )
516
- @asymmetric_sign = Google::Gax.create_api_call(
517
- @key_management_service_stub.method(:asymmetric_sign),
518
- defaults["asymmetric_sign"],
519
- exception_transformer: exception_transformer,
520
- params_extractor: proc do |request|
521
- {'name' => request.name}
522
- end
523
- )
524
- @set_iam_policy = Google::Gax.create_api_call(
525
- @iam_policy_stub.method(:set_iam_policy),
526
- defaults["set_iam_policy"],
527
- exception_transformer: exception_transformer,
528
- params_extractor: proc do |request|
529
- {'resource' => request.resource}
530
- end
531
- )
532
- @get_iam_policy = Google::Gax.create_api_call(
533
- @iam_policy_stub.method(:get_iam_policy),
534
- defaults["get_iam_policy"],
535
- exception_transformer: exception_transformer,
536
- params_extractor: proc do |request|
537
- {'resource' => request.resource}
538
- end
539
- )
540
- @test_iam_permissions = Google::Gax.create_api_call(
541
- @iam_policy_stub.method(:test_iam_permissions),
542
- defaults["test_iam_permissions"],
543
- exception_transformer: exception_transformer,
544
- params_extractor: proc do |request|
545
- {'resource' => request.resource}
546
- end
547
- )
548
- end
549
-
550
- # Service calls
551
-
552
- # Lists {Google::Cloud::Kms::V1::KeyRing KeyRings}.
553
- #
554
- # @param parent [String]
555
- # Required. The resource name of the location associated with the
556
- # {Google::Cloud::Kms::V1::KeyRing KeyRings}, in the format `projects/*/locations/*`.
557
- # @param page_size [Integer]
558
- # The maximum number of resources contained in the underlying API
559
- # response. If page streaming is performed per-resource, this
560
- # parameter does not affect the return value. If page streaming is
561
- # performed per-page, this determines the maximum number of
562
- # resources in a page.
563
- # @param filter [String]
564
- # Optional. Only include resources that match the filter in the response. For
565
- # more information, see
566
- # [Sorting and filtering list
567
- # results](https://cloud.google.com/kms/docs/sorting-and-filtering).
568
- # @param order_by [String]
569
- # Optional. Specify how the results should be sorted. If not specified, the
570
- # results will be sorted in the default order. For more information, see
571
- # [Sorting and filtering list
572
- # results](https://cloud.google.com/kms/docs/sorting-and-filtering).
573
- # @param options [Google::Gax::CallOptions]
574
- # Overrides the default settings for this call, e.g, timeout,
575
- # retries, etc.
576
- # @yield [result, operation] Access the result along with the RPC operation
577
- # @yieldparam result [Google::Gax::PagedEnumerable<Google::Cloud::Kms::V1::KeyRing>]
578
- # @yieldparam operation [GRPC::ActiveCall::Operation]
579
- # @return [Google::Gax::PagedEnumerable<Google::Cloud::Kms::V1::KeyRing>]
580
- # An enumerable of Google::Cloud::Kms::V1::KeyRing instances.
581
- # See Google::Gax::PagedEnumerable documentation for other
582
- # operations such as per-page iteration or access to the response
583
- # object.
584
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
585
- # @example
586
- # require "google/cloud/kms"
587
- #
588
- # key_management_client = Google::Cloud::Kms.new(version: :v1)
589
- # formatted_parent = Google::Cloud::Kms::V1::KeyManagementServiceClient.location_path("[PROJECT]", "[LOCATION]")
590
- #
591
- # # Iterate over all results.
592
- # key_management_client.list_key_rings(formatted_parent).each do |element|
593
- # # Process element.
594
- # end
595
- #
596
- # # Or iterate over results one page at a time.
597
- # key_management_client.list_key_rings(formatted_parent).each_page do |page|
598
- # # Process each page at a time.
599
- # page.each do |element|
600
- # # Process element.
601
- # end
602
- # end
603
-
604
- def list_key_rings \
605
- parent,
606
- page_size: nil,
607
- filter: nil,
608
- order_by: nil,
609
- options: nil,
610
- &block
611
- req = {
612
- parent: parent,
613
- page_size: page_size,
614
- filter: filter,
615
- order_by: order_by
616
- }.delete_if { |_, v| v.nil? }
617
- req = Google::Gax::to_proto(req, Google::Cloud::Kms::V1::ListKeyRingsRequest)
618
- @list_key_rings.call(req, options, &block)
619
- end
620
-
621
- # Lists {Google::Cloud::Kms::V1::ImportJob ImportJobs}.
622
- #
623
- # @param parent [String]
624
- # Required. The resource name of the {Google::Cloud::Kms::V1::KeyRing KeyRing} to list, in the format
625
- # `projects/*/locations/*/keyRings/*`.
626
- # @param page_size [Integer]
627
- # The maximum number of resources contained in the underlying API
628
- # response. If page streaming is performed per-resource, this
629
- # parameter does not affect the return value. If page streaming is
630
- # performed per-page, this determines the maximum number of
631
- # resources in a page.
632
- # @param filter [String]
633
- # Optional. Only include resources that match the filter in the response. For
634
- # more information, see
635
- # [Sorting and filtering list
636
- # results](https://cloud.google.com/kms/docs/sorting-and-filtering).
637
- # @param order_by [String]
638
- # Optional. Specify how the results should be sorted. If not specified, the
639
- # results will be sorted in the default order. For more information, see
640
- # [Sorting and filtering list
641
- # results](https://cloud.google.com/kms/docs/sorting-and-filtering).
642
- # @param options [Google::Gax::CallOptions]
643
- # Overrides the default settings for this call, e.g, timeout,
644
- # retries, etc.
645
- # @yield [result, operation] Access the result along with the RPC operation
646
- # @yieldparam result [Google::Gax::PagedEnumerable<Google::Cloud::Kms::V1::ImportJob>]
647
- # @yieldparam operation [GRPC::ActiveCall::Operation]
648
- # @return [Google::Gax::PagedEnumerable<Google::Cloud::Kms::V1::ImportJob>]
649
- # An enumerable of Google::Cloud::Kms::V1::ImportJob instances.
650
- # See Google::Gax::PagedEnumerable documentation for other
651
- # operations such as per-page iteration or access to the response
652
- # object.
653
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
654
- # @example
655
- # require "google/cloud/kms"
656
- #
657
- # key_management_client = Google::Cloud::Kms.new(version: :v1)
658
- # formatted_parent = Google::Cloud::Kms::V1::KeyManagementServiceClient.key_ring_path("[PROJECT]", "[LOCATION]", "[KEY_RING]")
659
- #
660
- # # Iterate over all results.
661
- # key_management_client.list_import_jobs(formatted_parent).each do |element|
662
- # # Process element.
663
- # end
664
- #
665
- # # Or iterate over results one page at a time.
666
- # key_management_client.list_import_jobs(formatted_parent).each_page do |page|
667
- # # Process each page at a time.
668
- # page.each do |element|
669
- # # Process element.
670
- # end
671
- # end
672
-
673
- def list_import_jobs \
674
- parent,
675
- page_size: nil,
676
- filter: nil,
677
- order_by: nil,
678
- options: nil,
679
- &block
680
- req = {
681
- parent: parent,
682
- page_size: page_size,
683
- filter: filter,
684
- order_by: order_by
685
- }.delete_if { |_, v| v.nil? }
686
- req = Google::Gax::to_proto(req, Google::Cloud::Kms::V1::ListImportJobsRequest)
687
- @list_import_jobs.call(req, options, &block)
688
- end
689
-
690
- # Lists {Google::Cloud::Kms::V1::CryptoKey CryptoKeys}.
691
- #
692
- # @param parent [String]
693
- # Required. The resource name of the {Google::Cloud::Kms::V1::KeyRing KeyRing} to list, in the format
694
- # `projects/*/locations/*/keyRings/*`.
695
- # @param page_size [Integer]
696
- # The maximum number of resources contained in the underlying API
697
- # response. If page streaming is performed per-resource, this
698
- # parameter does not affect the return value. If page streaming is
699
- # performed per-page, this determines the maximum number of
700
- # resources in a page.
701
- # @param version_view [Google::Cloud::Kms::V1::CryptoKeyVersion::CryptoKeyVersionView]
702
- # The fields of the primary version to include in the response.
703
- # @param filter [String]
704
- # Optional. Only include resources that match the filter in the response. For
705
- # more information, see
706
- # [Sorting and filtering list
707
- # results](https://cloud.google.com/kms/docs/sorting-and-filtering).
708
- # @param order_by [String]
709
- # Optional. Specify how the results should be sorted. If not specified, the
710
- # results will be sorted in the default order. For more information, see
711
- # [Sorting and filtering list
712
- # results](https://cloud.google.com/kms/docs/sorting-and-filtering).
713
- # @param options [Google::Gax::CallOptions]
714
- # Overrides the default settings for this call, e.g, timeout,
715
- # retries, etc.
716
- # @yield [result, operation] Access the result along with the RPC operation
717
- # @yieldparam result [Google::Gax::PagedEnumerable<Google::Cloud::Kms::V1::CryptoKey>]
718
- # @yieldparam operation [GRPC::ActiveCall::Operation]
719
- # @return [Google::Gax::PagedEnumerable<Google::Cloud::Kms::V1::CryptoKey>]
720
- # An enumerable of Google::Cloud::Kms::V1::CryptoKey instances.
721
- # See Google::Gax::PagedEnumerable documentation for other
722
- # operations such as per-page iteration or access to the response
723
- # object.
724
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
725
- # @example
726
- # require "google/cloud/kms"
727
- #
728
- # key_management_client = Google::Cloud::Kms.new(version: :v1)
729
- # formatted_parent = Google::Cloud::Kms::V1::KeyManagementServiceClient.key_ring_path("[PROJECT]", "[LOCATION]", "[KEY_RING]")
730
- #
731
- # # Iterate over all results.
732
- # key_management_client.list_crypto_keys(formatted_parent).each do |element|
733
- # # Process element.
734
- # end
735
- #
736
- # # Or iterate over results one page at a time.
737
- # key_management_client.list_crypto_keys(formatted_parent).each_page do |page|
738
- # # Process each page at a time.
739
- # page.each do |element|
740
- # # Process element.
741
- # end
742
- # end
743
-
744
- def list_crypto_keys \
745
- parent,
746
- page_size: nil,
747
- version_view: nil,
748
- filter: nil,
749
- order_by: nil,
750
- options: nil,
751
- &block
752
- req = {
753
- parent: parent,
754
- page_size: page_size,
755
- version_view: version_view,
756
- filter: filter,
757
- order_by: order_by
758
- }.delete_if { |_, v| v.nil? }
759
- req = Google::Gax::to_proto(req, Google::Cloud::Kms::V1::ListCryptoKeysRequest)
760
- @list_crypto_keys.call(req, options, &block)
761
- end
762
-
763
- # Lists {Google::Cloud::Kms::V1::CryptoKeyVersion CryptoKeyVersions}.
764
- #
765
- # @param parent [String]
766
- # Required. The resource name of the {Google::Cloud::Kms::V1::CryptoKey CryptoKey} to list, in the format
767
- # `projects/*/locations/*/keyRings/*/cryptoKeys/*`.
768
- # @param page_size [Integer]
769
- # The maximum number of resources contained in the underlying API
770
- # response. If page streaming is performed per-resource, this
771
- # parameter does not affect the return value. If page streaming is
772
- # performed per-page, this determines the maximum number of
773
- # resources in a page.
774
- # @param view [Google::Cloud::Kms::V1::CryptoKeyVersion::CryptoKeyVersionView]
775
- # The fields to include in the response.
776
- # @param filter [String]
777
- # Optional. Only include resources that match the filter in the response. For
778
- # more information, see
779
- # [Sorting and filtering list
780
- # results](https://cloud.google.com/kms/docs/sorting-and-filtering).
781
- # @param order_by [String]
782
- # Optional. Specify how the results should be sorted. If not specified, the
783
- # results will be sorted in the default order. For more information, see
784
- # [Sorting and filtering list
785
- # results](https://cloud.google.com/kms/docs/sorting-and-filtering).
786
- # @param options [Google::Gax::CallOptions]
787
- # Overrides the default settings for this call, e.g, timeout,
788
- # retries, etc.
789
- # @yield [result, operation] Access the result along with the RPC operation
790
- # @yieldparam result [Google::Gax::PagedEnumerable<Google::Cloud::Kms::V1::CryptoKeyVersion>]
791
- # @yieldparam operation [GRPC::ActiveCall::Operation]
792
- # @return [Google::Gax::PagedEnumerable<Google::Cloud::Kms::V1::CryptoKeyVersion>]
793
- # An enumerable of Google::Cloud::Kms::V1::CryptoKeyVersion instances.
794
- # See Google::Gax::PagedEnumerable documentation for other
795
- # operations such as per-page iteration or access to the response
796
- # object.
797
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
798
- # @example
799
- # require "google/cloud/kms"
800
- #
801
- # key_management_client = Google::Cloud::Kms.new(version: :v1)
802
- # formatted_parent = Google::Cloud::Kms::V1::KeyManagementServiceClient.crypto_key_path("[PROJECT]", "[LOCATION]", "[KEY_RING]", "[CRYPTO_KEY]")
803
- #
804
- # # Iterate over all results.
805
- # key_management_client.list_crypto_key_versions(formatted_parent).each do |element|
806
- # # Process element.
807
- # end
808
- #
809
- # # Or iterate over results one page at a time.
810
- # key_management_client.list_crypto_key_versions(formatted_parent).each_page do |page|
811
- # # Process each page at a time.
812
- # page.each do |element|
813
- # # Process element.
814
- # end
815
- # end
816
-
817
- def list_crypto_key_versions \
818
- parent,
819
- page_size: nil,
820
- view: nil,
821
- filter: nil,
822
- order_by: nil,
823
- options: nil,
824
- &block
825
- req = {
826
- parent: parent,
827
- page_size: page_size,
828
- view: view,
829
- filter: filter,
830
- order_by: order_by
831
- }.delete_if { |_, v| v.nil? }
832
- req = Google::Gax::to_proto(req, Google::Cloud::Kms::V1::ListCryptoKeyVersionsRequest)
833
- @list_crypto_key_versions.call(req, options, &block)
834
- end
835
-
836
- # Returns metadata for a given {Google::Cloud::Kms::V1::KeyRing KeyRing}.
837
- #
838
- # @param name [String]
839
- # Required. The {Google::Cloud::Kms::V1::KeyRing#name name} of the {Google::Cloud::Kms::V1::KeyRing KeyRing} to get.
840
- # @param options [Google::Gax::CallOptions]
841
- # Overrides the default settings for this call, e.g, timeout,
842
- # retries, etc.
843
- # @yield [result, operation] Access the result along with the RPC operation
844
- # @yieldparam result [Google::Cloud::Kms::V1::KeyRing]
845
- # @yieldparam operation [GRPC::ActiveCall::Operation]
846
- # @return [Google::Cloud::Kms::V1::KeyRing]
847
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
848
- # @example
849
- # require "google/cloud/kms"
850
- #
851
- # key_management_client = Google::Cloud::Kms.new(version: :v1)
852
- # formatted_name = Google::Cloud::Kms::V1::KeyManagementServiceClient.key_ring_path("[PROJECT]", "[LOCATION]", "[KEY_RING]")
853
- # response = key_management_client.get_key_ring(formatted_name)
854
-
855
- def get_key_ring \
856
- name,
857
- options: nil,
858
- &block
859
- req = {
860
- name: name
861
- }.delete_if { |_, v| v.nil? }
862
- req = Google::Gax::to_proto(req, Google::Cloud::Kms::V1::GetKeyRingRequest)
863
- @get_key_ring.call(req, options, &block)
864
- end
865
-
866
- # Returns metadata for a given {Google::Cloud::Kms::V1::ImportJob ImportJob}.
867
- #
868
- # @param name [String]
869
- # Required. The {Google::Cloud::Kms::V1::ImportJob#name name} of the {Google::Cloud::Kms::V1::ImportJob ImportJob} to get.
870
- # @param options [Google::Gax::CallOptions]
871
- # Overrides the default settings for this call, e.g, timeout,
872
- # retries, etc.
873
- # @yield [result, operation] Access the result along with the RPC operation
874
- # @yieldparam result [Google::Cloud::Kms::V1::ImportJob]
875
- # @yieldparam operation [GRPC::ActiveCall::Operation]
876
- # @return [Google::Cloud::Kms::V1::ImportJob]
877
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
878
- # @example
879
- # require "google/cloud/kms"
880
- #
881
- # key_management_client = Google::Cloud::Kms.new(version: :v1)
882
- # formatted_name = Google::Cloud::Kms::V1::KeyManagementServiceClient.import_job_path("[PROJECT]", "[LOCATION]", "[KEY_RING]", "[IMPORT_JOB]")
883
- # response = key_management_client.get_import_job(formatted_name)
884
-
885
- def get_import_job \
886
- name,
887
- options: nil,
888
- &block
889
- req = {
890
- name: name
891
- }.delete_if { |_, v| v.nil? }
892
- req = Google::Gax::to_proto(req, Google::Cloud::Kms::V1::GetImportJobRequest)
893
- @get_import_job.call(req, options, &block)
894
- end
895
-
896
- # Returns metadata for a given {Google::Cloud::Kms::V1::CryptoKey CryptoKey}, as well as its
897
- # {Google::Cloud::Kms::V1::CryptoKey#primary primary} {Google::Cloud::Kms::V1::CryptoKeyVersion CryptoKeyVersion}.
898
- #
899
- # @param name [String]
900
- # Required. The {Google::Cloud::Kms::V1::CryptoKey#name name} of the {Google::Cloud::Kms::V1::CryptoKey CryptoKey} to get.
901
- # @param options [Google::Gax::CallOptions]
902
- # Overrides the default settings for this call, e.g, timeout,
903
- # retries, etc.
904
- # @yield [result, operation] Access the result along with the RPC operation
905
- # @yieldparam result [Google::Cloud::Kms::V1::CryptoKey]
906
- # @yieldparam operation [GRPC::ActiveCall::Operation]
907
- # @return [Google::Cloud::Kms::V1::CryptoKey]
908
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
909
- # @example
910
- # require "google/cloud/kms"
911
- #
912
- # key_management_client = Google::Cloud::Kms.new(version: :v1)
913
- # formatted_name = Google::Cloud::Kms::V1::KeyManagementServiceClient.crypto_key_path("[PROJECT]", "[LOCATION]", "[KEY_RING]", "[CRYPTO_KEY]")
914
- # response = key_management_client.get_crypto_key(formatted_name)
915
-
916
- def get_crypto_key \
917
- name,
918
- options: nil,
919
- &block
920
- req = {
921
- name: name
922
- }.delete_if { |_, v| v.nil? }
923
- req = Google::Gax::to_proto(req, Google::Cloud::Kms::V1::GetCryptoKeyRequest)
924
- @get_crypto_key.call(req, options, &block)
925
- end
926
-
927
- # Returns metadata for a given {Google::Cloud::Kms::V1::CryptoKeyVersion CryptoKeyVersion}.
928
- #
929
- # @param name [String]
930
- # Required. The {Google::Cloud::Kms::V1::CryptoKeyVersion#name name} of the {Google::Cloud::Kms::V1::CryptoKeyVersion CryptoKeyVersion} to get.
931
- # @param options [Google::Gax::CallOptions]
932
- # Overrides the default settings for this call, e.g, timeout,
933
- # retries, etc.
934
- # @yield [result, operation] Access the result along with the RPC operation
935
- # @yieldparam result [Google::Cloud::Kms::V1::CryptoKeyVersion]
936
- # @yieldparam operation [GRPC::ActiveCall::Operation]
937
- # @return [Google::Cloud::Kms::V1::CryptoKeyVersion]
938
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
939
- # @example
940
- # require "google/cloud/kms"
941
- #
942
- # key_management_client = Google::Cloud::Kms.new(version: :v1)
943
- # formatted_name = Google::Cloud::Kms::V1::KeyManagementServiceClient.crypto_key_version_path("[PROJECT]", "[LOCATION]", "[KEY_RING]", "[CRYPTO_KEY]", "[CRYPTO_KEY_VERSION]")
944
- # response = key_management_client.get_crypto_key_version(formatted_name)
945
-
946
- def get_crypto_key_version \
947
- name,
948
- options: nil,
949
- &block
950
- req = {
951
- name: name
952
- }.delete_if { |_, v| v.nil? }
953
- req = Google::Gax::to_proto(req, Google::Cloud::Kms::V1::GetCryptoKeyVersionRequest)
954
- @get_crypto_key_version.call(req, options, &block)
955
- end
956
-
957
- # Create a new {Google::Cloud::Kms::V1::KeyRing KeyRing} in a given Project and Location.
958
- #
959
- # @param parent [String]
960
- # Required. The resource name of the location associated with the
961
- # {Google::Cloud::Kms::V1::KeyRing KeyRings}, in the format `projects/*/locations/*`.
962
- # @param key_ring_id [String]
963
- # Required. It must be unique within a location and match the regular
964
- # expression `[a-zA-Z0-9_-]{1,63}`
965
- # @param key_ring [Google::Cloud::Kms::V1::KeyRing | Hash]
966
- # Required. A {Google::Cloud::Kms::V1::KeyRing KeyRing} with initial field values.
967
- # A hash of the same form as `Google::Cloud::Kms::V1::KeyRing`
968
- # can also be provided.
969
- # @param options [Google::Gax::CallOptions]
970
- # Overrides the default settings for this call, e.g, timeout,
971
- # retries, etc.
972
- # @yield [result, operation] Access the result along with the RPC operation
973
- # @yieldparam result [Google::Cloud::Kms::V1::KeyRing]
974
- # @yieldparam operation [GRPC::ActiveCall::Operation]
975
- # @return [Google::Cloud::Kms::V1::KeyRing]
976
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
977
- # @example
978
- # require "google/cloud/kms"
979
- #
980
- # key_management_client = Google::Cloud::Kms.new(version: :v1)
981
- # formatted_parent = Google::Cloud::Kms::V1::KeyManagementServiceClient.location_path("[PROJECT]", "[LOCATION]")
982
- #
983
- # # TODO: Initialize `key_ring_id`:
984
- # key_ring_id = ''
985
- #
986
- # # TODO: Initialize `key_ring`:
987
- # key_ring = {}
988
- # response = key_management_client.create_key_ring(formatted_parent, key_ring_id, key_ring)
989
-
990
- def create_key_ring \
991
- parent,
992
- key_ring_id,
993
- key_ring,
994
- options: nil,
995
- &block
996
- req = {
997
- parent: parent,
998
- key_ring_id: key_ring_id,
999
- key_ring: key_ring
1000
- }.delete_if { |_, v| v.nil? }
1001
- req = Google::Gax::to_proto(req, Google::Cloud::Kms::V1::CreateKeyRingRequest)
1002
- @create_key_ring.call(req, options, &block)
1003
- end
1004
-
1005
- # Create a new {Google::Cloud::Kms::V1::ImportJob ImportJob} within a {Google::Cloud::Kms::V1::KeyRing KeyRing}.
1006
- #
1007
- # {Google::Cloud::Kms::V1::ImportJob#import_method ImportJob#import_method} is required.
1008
- #
1009
- # @param parent [String]
1010
- # Required. The {Google::Cloud::Kms::V1::KeyRing#name name} of the {Google::Cloud::Kms::V1::KeyRing KeyRing} associated with the
1011
- # {Google::Cloud::Kms::V1::ImportJob ImportJobs}.
1012
- # @param import_job_id [String]
1013
- # Required. It must be unique within a KeyRing and match the regular
1014
- # expression `[a-zA-Z0-9_-]{1,63}`
1015
- # @param import_job [Google::Cloud::Kms::V1::ImportJob | Hash]
1016
- # Required. An {Google::Cloud::Kms::V1::ImportJob ImportJob} with initial field values.
1017
- # A hash of the same form as `Google::Cloud::Kms::V1::ImportJob`
1018
- # can also be provided.
1019
- # @param options [Google::Gax::CallOptions]
1020
- # Overrides the default settings for this call, e.g, timeout,
1021
- # retries, etc.
1022
- # @yield [result, operation] Access the result along with the RPC operation
1023
- # @yieldparam result [Google::Cloud::Kms::V1::ImportJob]
1024
- # @yieldparam operation [GRPC::ActiveCall::Operation]
1025
- # @return [Google::Cloud::Kms::V1::ImportJob]
1026
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
1027
- # @example
1028
- # require "google/cloud/kms"
1029
- #
1030
- # key_management_client = Google::Cloud::Kms.new(version: :v1)
1031
- # formatted_parent = Google::Cloud::Kms::V1::KeyManagementServiceClient.key_ring_path("[PROJECT]", "[LOCATION]", "[KEY_RING]")
1032
- # import_job_id = "my-import-job"
1033
- # import_method = :RSA_OAEP_3072_SHA1_AES_256
1034
- # protection_level = :HSM
1035
- # import_job = { import_method: import_method, protection_level: protection_level }
1036
- # response = key_management_client.create_import_job(formatted_parent, import_job_id, import_job)
1037
-
1038
- def create_import_job \
1039
- parent,
1040
- import_job_id,
1041
- import_job,
1042
- options: nil,
1043
- &block
1044
- req = {
1045
- parent: parent,
1046
- import_job_id: import_job_id,
1047
- import_job: import_job
1048
- }.delete_if { |_, v| v.nil? }
1049
- req = Google::Gax::to_proto(req, Google::Cloud::Kms::V1::CreateImportJobRequest)
1050
- @create_import_job.call(req, options, &block)
1051
- end
1052
-
1053
- # Create a new {Google::Cloud::Kms::V1::CryptoKey CryptoKey} within a {Google::Cloud::Kms::V1::KeyRing KeyRing}.
1054
- #
1055
- # {Google::Cloud::Kms::V1::CryptoKey#purpose CryptoKey#purpose} and
1056
- # {Google::Cloud::Kms::V1::CryptoKeyVersionTemplate#algorithm CryptoKey#version_template#algorithm}
1057
- # are required.
1058
- #
1059
- # @param parent [String]
1060
- # Required. The {Google::Cloud::Kms::V1::KeyRing#name name} of the KeyRing associated with the
1061
- # {Google::Cloud::Kms::V1::CryptoKey CryptoKeys}.
1062
- # @param crypto_key_id [String]
1063
- # Required. It must be unique within a KeyRing and match the regular
1064
- # expression `[a-zA-Z0-9_-]{1,63}`
1065
- # @param crypto_key [Google::Cloud::Kms::V1::CryptoKey | Hash]
1066
- # Required. A {Google::Cloud::Kms::V1::CryptoKey CryptoKey} with initial field values.
1067
- # A hash of the same form as `Google::Cloud::Kms::V1::CryptoKey`
1068
- # can also be provided.
1069
- # @param skip_initial_version_creation [true, false]
1070
- # If set to true, the request will create a {Google::Cloud::Kms::V1::CryptoKey CryptoKey} without any
1071
- # {Google::Cloud::Kms::V1::CryptoKeyVersion CryptoKeyVersions}. You must manually call
1072
- # {Google::Cloud::Kms::V1::KeyManagementService::CreateCryptoKeyVersion CreateCryptoKeyVersion} or
1073
- # {Google::Cloud::Kms::V1::KeyManagementService::ImportCryptoKeyVersion ImportCryptoKeyVersion}
1074
- # before you can use this {Google::Cloud::Kms::V1::CryptoKey CryptoKey}.
1075
- # @param options [Google::Gax::CallOptions]
1076
- # Overrides the default settings for this call, e.g, timeout,
1077
- # retries, etc.
1078
- # @yield [result, operation] Access the result along with the RPC operation
1079
- # @yieldparam result [Google::Cloud::Kms::V1::CryptoKey]
1080
- # @yieldparam operation [GRPC::ActiveCall::Operation]
1081
- # @return [Google::Cloud::Kms::V1::CryptoKey]
1082
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
1083
- # @example
1084
- # require "google/cloud/kms"
1085
- #
1086
- # key_management_client = Google::Cloud::Kms.new(version: :v1)
1087
- # formatted_parent = Google::Cloud::Kms::V1::KeyManagementServiceClient.key_ring_path("[PROJECT]", "[LOCATION]", "[KEY_RING]")
1088
- # crypto_key_id = "my-app-key"
1089
- # purpose = :ENCRYPT_DECRYPT
1090
- # seconds = 2147483647
1091
- # next_rotation_time = { seconds: seconds }
1092
- # seconds_2 = 604800
1093
- # rotation_period = { seconds: seconds_2 }
1094
- # crypto_key = {
1095
- # purpose: purpose,
1096
- # next_rotation_time: next_rotation_time,
1097
- # rotation_period: rotation_period
1098
- # }
1099
- # response = key_management_client.create_crypto_key(formatted_parent, crypto_key_id, crypto_key)
1100
-
1101
- def create_crypto_key \
1102
- parent,
1103
- crypto_key_id,
1104
- crypto_key,
1105
- skip_initial_version_creation: nil,
1106
- options: nil,
1107
- &block
1108
- req = {
1109
- parent: parent,
1110
- crypto_key_id: crypto_key_id,
1111
- crypto_key: crypto_key,
1112
- skip_initial_version_creation: skip_initial_version_creation
1113
- }.delete_if { |_, v| v.nil? }
1114
- req = Google::Gax::to_proto(req, Google::Cloud::Kms::V1::CreateCryptoKeyRequest)
1115
- @create_crypto_key.call(req, options, &block)
1116
- end
1117
-
1118
- # Create a new {Google::Cloud::Kms::V1::CryptoKeyVersion CryptoKeyVersion} in a {Google::Cloud::Kms::V1::CryptoKey CryptoKey}.
1119
- #
1120
- # The server will assign the next sequential id. If unset,
1121
- # {Google::Cloud::Kms::V1::CryptoKeyVersion#state state} will be set to
1122
- # {Google::Cloud::Kms::V1::CryptoKeyVersion::CryptoKeyVersionState::ENABLED ENABLED}.
1123
- #
1124
- # @param parent [String]
1125
- # Required. The {Google::Cloud::Kms::V1::CryptoKey#name name} of the {Google::Cloud::Kms::V1::CryptoKey CryptoKey} associated with
1126
- # the {Google::Cloud::Kms::V1::CryptoKeyVersion CryptoKeyVersions}.
1127
- # @param crypto_key_version [Google::Cloud::Kms::V1::CryptoKeyVersion | Hash]
1128
- # Required. A {Google::Cloud::Kms::V1::CryptoKeyVersion CryptoKeyVersion} with initial field values.
1129
- # A hash of the same form as `Google::Cloud::Kms::V1::CryptoKeyVersion`
1130
- # can also be provided.
1131
- # @param options [Google::Gax::CallOptions]
1132
- # Overrides the default settings for this call, e.g, timeout,
1133
- # retries, etc.
1134
- # @yield [result, operation] Access the result along with the RPC operation
1135
- # @yieldparam result [Google::Cloud::Kms::V1::CryptoKeyVersion]
1136
- # @yieldparam operation [GRPC::ActiveCall::Operation]
1137
- # @return [Google::Cloud::Kms::V1::CryptoKeyVersion]
1138
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
1139
- # @example
1140
- # require "google/cloud/kms"
1141
- #
1142
- # key_management_client = Google::Cloud::Kms.new(version: :v1)
1143
- # formatted_parent = Google::Cloud::Kms::V1::KeyManagementServiceClient.crypto_key_path("[PROJECT]", "[LOCATION]", "[KEY_RING]", "[CRYPTO_KEY]")
1144
- #
1145
- # # TODO: Initialize `crypto_key_version`:
1146
- # crypto_key_version = {}
1147
- # response = key_management_client.create_crypto_key_version(formatted_parent, crypto_key_version)
1148
-
1149
- def create_crypto_key_version \
1150
- parent,
1151
- crypto_key_version,
1152
- options: nil,
1153
- &block
1154
- req = {
1155
- parent: parent,
1156
- crypto_key_version: crypto_key_version
1157
- }.delete_if { |_, v| v.nil? }
1158
- req = Google::Gax::to_proto(req, Google::Cloud::Kms::V1::CreateCryptoKeyVersionRequest)
1159
- @create_crypto_key_version.call(req, options, &block)
1160
- end
1161
-
1162
- # Imports a new {Google::Cloud::Kms::V1::CryptoKeyVersion CryptoKeyVersion} into an existing {Google::Cloud::Kms::V1::CryptoKey CryptoKey} using the
1163
- # wrapped key material provided in the request.
1164
- #
1165
- # The version ID will be assigned the next sequential id within the
1166
- # {Google::Cloud::Kms::V1::CryptoKey CryptoKey}.
1167
- #
1168
- # @param parent [String]
1169
- # Required. The {Google::Cloud::Kms::V1::CryptoKey#name name} of the {Google::Cloud::Kms::V1::CryptoKey CryptoKey} to
1170
- # be imported into.
1171
- # @param algorithm [Google::Cloud::Kms::V1::CryptoKeyVersion::CryptoKeyVersionAlgorithm]
1172
- # Required. The {Google::Cloud::Kms::V1::CryptoKeyVersion::CryptoKeyVersionAlgorithm algorithm} of
1173
- # the key being imported. This does not need to match the
1174
- # {Google::Cloud::Kms::V1::CryptoKey#version_template version_template} of the {Google::Cloud::Kms::V1::CryptoKey CryptoKey} this
1175
- # version imports into.
1176
- # @param import_job [String]
1177
- # Required. The {Google::Cloud::Kms::V1::ImportJob#name name} of the {Google::Cloud::Kms::V1::ImportJob ImportJob} that was used to
1178
- # wrap this key material.
1179
- # @param rsa_aes_wrapped_key [String]
1180
- # Wrapped key material produced with
1181
- # {Google::Cloud::Kms::V1::ImportJob::ImportMethod::RSA_OAEP_3072_SHA1_AES_256 RSA_OAEP_3072_SHA1_AES_256}
1182
- # or
1183
- # {Google::Cloud::Kms::V1::ImportJob::ImportMethod::RSA_OAEP_4096_SHA1_AES_256 RSA_OAEP_4096_SHA1_AES_256}.
1184
- #
1185
- # This field contains the concatenation of two wrapped keys:
1186
- # <ol>
1187
- # <li>An ephemeral AES-256 wrapping key wrapped with the
1188
- # {Google::Cloud::Kms::V1::ImportJob#public_key public_key} using RSAES-OAEP with SHA-1,
1189
- # MGF1 with SHA-1, and an empty label.
1190
- # </li>
1191
- # <li>The key to be imported, wrapped with the ephemeral AES-256 key
1192
- # using AES-KWP (RFC 5649).
1193
- # </li>
1194
- # </ol>
1195
- #
1196
- # If importing symmetric key material, it is expected that the unwrapped
1197
- # key contains plain bytes. If importing asymmetric key material, it is
1198
- # expected that the unwrapped key is in PKCS#8-encoded DER format (the
1199
- # PrivateKeyInfo structure from RFC 5208).
1200
- #
1201
- # This format is the same as the format produced by PKCS#11 mechanism
1202
- # CKM_RSA_AES_KEY_WRAP.
1203
- # @param options [Google::Gax::CallOptions]
1204
- # Overrides the default settings for this call, e.g, timeout,
1205
- # retries, etc.
1206
- # @yield [result, operation] Access the result along with the RPC operation
1207
- # @yieldparam result [Google::Cloud::Kms::V1::CryptoKeyVersion]
1208
- # @yieldparam operation [GRPC::ActiveCall::Operation]
1209
- # @return [Google::Cloud::Kms::V1::CryptoKeyVersion]
1210
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
1211
- # @example
1212
- # require "google/cloud/kms"
1213
- #
1214
- # key_management_client = Google::Cloud::Kms.new(version: :v1)
1215
- # formatted_parent = Google::Cloud::Kms::V1::KeyManagementServiceClient.crypto_key_path("[PROJECT]", "[LOCATION]", "[KEY_RING]", "[CRYPTO_KEY]")
1216
- #
1217
- # # TODO: Initialize `algorithm`:
1218
- # algorithm = :CRYPTO_KEY_VERSION_ALGORITHM_UNSPECIFIED
1219
- #
1220
- # # TODO: Initialize `import_job`:
1221
- # import_job = ''
1222
- # response = key_management_client.import_crypto_key_version(formatted_parent, algorithm, import_job)
1223
-
1224
- def import_crypto_key_version \
1225
- parent,
1226
- algorithm,
1227
- import_job,
1228
- rsa_aes_wrapped_key: nil,
1229
- options: nil,
1230
- &block
1231
- req = {
1232
- parent: parent,
1233
- algorithm: algorithm,
1234
- import_job: import_job,
1235
- rsa_aes_wrapped_key: rsa_aes_wrapped_key
1236
- }.delete_if { |_, v| v.nil? }
1237
- req = Google::Gax::to_proto(req, Google::Cloud::Kms::V1::ImportCryptoKeyVersionRequest)
1238
- @import_crypto_key_version.call(req, options, &block)
1239
- end
1240
-
1241
- # Update a {Google::Cloud::Kms::V1::CryptoKey CryptoKey}.
1242
- #
1243
- # @param crypto_key [Google::Cloud::Kms::V1::CryptoKey | Hash]
1244
- # Required. {Google::Cloud::Kms::V1::CryptoKey CryptoKey} with updated values.
1245
- # A hash of the same form as `Google::Cloud::Kms::V1::CryptoKey`
1246
- # can also be provided.
1247
- # @param update_mask [Google::Protobuf::FieldMask | Hash]
1248
- # Required. List of fields to be updated in this request.
1249
- # A hash of the same form as `Google::Protobuf::FieldMask`
1250
- # can also be provided.
1251
- # @param options [Google::Gax::CallOptions]
1252
- # Overrides the default settings for this call, e.g, timeout,
1253
- # retries, etc.
1254
- # @yield [result, operation] Access the result along with the RPC operation
1255
- # @yieldparam result [Google::Cloud::Kms::V1::CryptoKey]
1256
- # @yieldparam operation [GRPC::ActiveCall::Operation]
1257
- # @return [Google::Cloud::Kms::V1::CryptoKey]
1258
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
1259
- # @example
1260
- # require "google/cloud/kms"
1261
- #
1262
- # key_management_client = Google::Cloud::Kms.new(version: :v1)
1263
- #
1264
- # # TODO: Initialize `crypto_key`:
1265
- # crypto_key = {}
1266
- #
1267
- # # TODO: Initialize `update_mask`:
1268
- # update_mask = {}
1269
- # response = key_management_client.update_crypto_key(crypto_key, update_mask)
1270
-
1271
- def update_crypto_key \
1272
- crypto_key,
1273
- update_mask,
1274
- options: nil,
1275
- &block
1276
- req = {
1277
- crypto_key: crypto_key,
1278
- update_mask: update_mask
1279
- }.delete_if { |_, v| v.nil? }
1280
- req = Google::Gax::to_proto(req, Google::Cloud::Kms::V1::UpdateCryptoKeyRequest)
1281
- @update_crypto_key.call(req, options, &block)
1282
- end
1283
-
1284
- # Update a {Google::Cloud::Kms::V1::CryptoKeyVersion CryptoKeyVersion}'s metadata.
1285
- #
1286
- # {Google::Cloud::Kms::V1::CryptoKeyVersion#state state} may be changed between
1287
- # {Google::Cloud::Kms::V1::CryptoKeyVersion::CryptoKeyVersionState::ENABLED ENABLED} and
1288
- # {Google::Cloud::Kms::V1::CryptoKeyVersion::CryptoKeyVersionState::DISABLED DISABLED} using this
1289
- # method. See {Google::Cloud::Kms::V1::KeyManagementService::DestroyCryptoKeyVersion DestroyCryptoKeyVersion} and {Google::Cloud::Kms::V1::KeyManagementService::RestoreCryptoKeyVersion RestoreCryptoKeyVersion} to
1290
- # move between other states.
1291
- #
1292
- # @param crypto_key_version [Google::Cloud::Kms::V1::CryptoKeyVersion | Hash]
1293
- # Required. {Google::Cloud::Kms::V1::CryptoKeyVersion CryptoKeyVersion} with updated values.
1294
- # A hash of the same form as `Google::Cloud::Kms::V1::CryptoKeyVersion`
1295
- # can also be provided.
1296
- # @param update_mask [Google::Protobuf::FieldMask | Hash]
1297
- # Required. List of fields to be updated in this request.
1298
- # A hash of the same form as `Google::Protobuf::FieldMask`
1299
- # can also be provided.
1300
- # @param options [Google::Gax::CallOptions]
1301
- # Overrides the default settings for this call, e.g, timeout,
1302
- # retries, etc.
1303
- # @yield [result, operation] Access the result along with the RPC operation
1304
- # @yieldparam result [Google::Cloud::Kms::V1::CryptoKeyVersion]
1305
- # @yieldparam operation [GRPC::ActiveCall::Operation]
1306
- # @return [Google::Cloud::Kms::V1::CryptoKeyVersion]
1307
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
1308
- # @example
1309
- # require "google/cloud/kms"
1310
- #
1311
- # key_management_client = Google::Cloud::Kms.new(version: :v1)
1312
- #
1313
- # # TODO: Initialize `crypto_key_version`:
1314
- # crypto_key_version = {}
1315
- #
1316
- # # TODO: Initialize `update_mask`:
1317
- # update_mask = {}
1318
- # response = key_management_client.update_crypto_key_version(crypto_key_version, update_mask)
1319
-
1320
- def update_crypto_key_version \
1321
- crypto_key_version,
1322
- update_mask,
1323
- options: nil,
1324
- &block
1325
- req = {
1326
- crypto_key_version: crypto_key_version,
1327
- update_mask: update_mask
1328
- }.delete_if { |_, v| v.nil? }
1329
- req = Google::Gax::to_proto(req, Google::Cloud::Kms::V1::UpdateCryptoKeyVersionRequest)
1330
- @update_crypto_key_version.call(req, options, &block)
1331
- end
1332
-
1333
- # Encrypts data, so that it can only be recovered by a call to {Google::Cloud::Kms::V1::KeyManagementService::Decrypt Decrypt}.
1334
- # The {Google::Cloud::Kms::V1::CryptoKey#purpose CryptoKey#purpose} must be
1335
- # {Google::Cloud::Kms::V1::CryptoKey::CryptoKeyPurpose::ENCRYPT_DECRYPT ENCRYPT_DECRYPT}.
1336
- #
1337
- # @param name [String]
1338
- # Required. The resource name of the {Google::Cloud::Kms::V1::CryptoKey CryptoKey} or {Google::Cloud::Kms::V1::CryptoKeyVersion CryptoKeyVersion}
1339
- # to use for encryption.
1340
- #
1341
- # If a {Google::Cloud::Kms::V1::CryptoKey CryptoKey} is specified, the server will use its
1342
- # {Google::Cloud::Kms::V1::CryptoKey#primary primary version}.
1343
- # @param plaintext [String]
1344
- # Required. The data to encrypt. Must be no larger than 64KiB.
1345
- #
1346
- # The maximum size depends on the key version's
1347
- # {Google::Cloud::Kms::V1::CryptoKeyVersionTemplate#protection_level protection_level}. For
1348
- # {Google::Cloud::Kms::V1::ProtectionLevel::SOFTWARE SOFTWARE} keys, the plaintext must be no larger
1349
- # than 64KiB. For {Google::Cloud::Kms::V1::ProtectionLevel::HSM HSM} keys, the combined length of the
1350
- # plaintext and additional_authenticated_data fields must be no larger than
1351
- # 8KiB.
1352
- # @param additional_authenticated_data [String]
1353
- # Optional. Optional data that, if specified, must also be provided during decryption
1354
- # through {Google::Cloud::Kms::V1::DecryptRequest#additional_authenticated_data DecryptRequest#additional_authenticated_data}.
1355
- #
1356
- # The maximum size depends on the key version's
1357
- # {Google::Cloud::Kms::V1::CryptoKeyVersionTemplate#protection_level protection_level}. For
1358
- # {Google::Cloud::Kms::V1::ProtectionLevel::SOFTWARE SOFTWARE} keys, the AAD must be no larger than
1359
- # 64KiB. For {Google::Cloud::Kms::V1::ProtectionLevel::HSM HSM} keys, the combined length of the
1360
- # plaintext and additional_authenticated_data fields must be no larger than
1361
- # 8KiB.
1362
- # @param options [Google::Gax::CallOptions]
1363
- # Overrides the default settings for this call, e.g, timeout,
1364
- # retries, etc.
1365
- # @yield [result, operation] Access the result along with the RPC operation
1366
- # @yieldparam result [Google::Cloud::Kms::V1::EncryptResponse]
1367
- # @yieldparam operation [GRPC::ActiveCall::Operation]
1368
- # @return [Google::Cloud::Kms::V1::EncryptResponse]
1369
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
1370
- # @example
1371
- # require "google/cloud/kms"
1372
- #
1373
- # key_management_client = Google::Cloud::Kms.new(version: :v1)
1374
- # formatted_name = Google::Cloud::Kms::V1::KeyManagementServiceClient.crypto_key_path_path("[PROJECT]", "[LOCATION]", "[KEY_RING]", "[CRYPTO_KEY_PATH]")
1375
- #
1376
- # # TODO: Initialize `plaintext`:
1377
- # plaintext = ''
1378
- # response = key_management_client.encrypt(formatted_name, plaintext)
1379
-
1380
- def encrypt \
1381
- name,
1382
- plaintext,
1383
- additional_authenticated_data: nil,
1384
- options: nil,
1385
- &block
1386
- req = {
1387
- name: name,
1388
- plaintext: plaintext,
1389
- additional_authenticated_data: additional_authenticated_data
1390
- }.delete_if { |_, v| v.nil? }
1391
- req = Google::Gax::to_proto(req, Google::Cloud::Kms::V1::EncryptRequest)
1392
- @encrypt.call(req, options, &block)
1393
- end
1394
-
1395
- # Decrypts data that was protected by {Google::Cloud::Kms::V1::KeyManagementService::Encrypt Encrypt}. The {Google::Cloud::Kms::V1::CryptoKey#purpose CryptoKey#purpose}
1396
- # must be {Google::Cloud::Kms::V1::CryptoKey::CryptoKeyPurpose::ENCRYPT_DECRYPT ENCRYPT_DECRYPT}.
1397
- #
1398
- # @param name [String]
1399
- # Required. The resource name of the {Google::Cloud::Kms::V1::CryptoKey CryptoKey} to use for decryption.
1400
- # The server will choose the appropriate version.
1401
- # @param ciphertext [String]
1402
- # Required. The encrypted data originally returned in
1403
- # {Google::Cloud::Kms::V1::EncryptResponse#ciphertext EncryptResponse#ciphertext}.
1404
- # @param additional_authenticated_data [String]
1405
- # Optional. Optional data that must match the data originally supplied in
1406
- # {Google::Cloud::Kms::V1::EncryptRequest#additional_authenticated_data EncryptRequest#additional_authenticated_data}.
1407
- # @param options [Google::Gax::CallOptions]
1408
- # Overrides the default settings for this call, e.g, timeout,
1409
- # retries, etc.
1410
- # @yield [result, operation] Access the result along with the RPC operation
1411
- # @yieldparam result [Google::Cloud::Kms::V1::DecryptResponse]
1412
- # @yieldparam operation [GRPC::ActiveCall::Operation]
1413
- # @return [Google::Cloud::Kms::V1::DecryptResponse]
1414
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
1415
- # @example
1416
- # require "google/cloud/kms"
1417
- #
1418
- # key_management_client = Google::Cloud::Kms.new(version: :v1)
1419
- # formatted_name = Google::Cloud::Kms::V1::KeyManagementServiceClient.crypto_key_path("[PROJECT]", "[LOCATION]", "[KEY_RING]", "[CRYPTO_KEY]")
1420
- #
1421
- # # TODO: Initialize `ciphertext`:
1422
- # ciphertext = ''
1423
- # response = key_management_client.decrypt(formatted_name, ciphertext)
1424
-
1425
- def decrypt \
1426
- name,
1427
- ciphertext,
1428
- additional_authenticated_data: nil,
1429
- options: nil,
1430
- &block
1431
- req = {
1432
- name: name,
1433
- ciphertext: ciphertext,
1434
- additional_authenticated_data: additional_authenticated_data
1435
- }.delete_if { |_, v| v.nil? }
1436
- req = Google::Gax::to_proto(req, Google::Cloud::Kms::V1::DecryptRequest)
1437
- @decrypt.call(req, options, &block)
1438
- end
1439
-
1440
- # Update the version of a {Google::Cloud::Kms::V1::CryptoKey CryptoKey} that will be used in {Google::Cloud::Kms::V1::KeyManagementService::Encrypt Encrypt}.
1441
- #
1442
- # Returns an error if called on an asymmetric key.
1443
- #
1444
- # @param name [String]
1445
- # Required. The resource name of the {Google::Cloud::Kms::V1::CryptoKey CryptoKey} to update.
1446
- # @param crypto_key_version_id [String]
1447
- # Required. The id of the child {Google::Cloud::Kms::V1::CryptoKeyVersion CryptoKeyVersion} to use as primary.
1448
- # @param options [Google::Gax::CallOptions]
1449
- # Overrides the default settings for this call, e.g, timeout,
1450
- # retries, etc.
1451
- # @yield [result, operation] Access the result along with the RPC operation
1452
- # @yieldparam result [Google::Cloud::Kms::V1::CryptoKey]
1453
- # @yieldparam operation [GRPC::ActiveCall::Operation]
1454
- # @return [Google::Cloud::Kms::V1::CryptoKey]
1455
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
1456
- # @example
1457
- # require "google/cloud/kms"
1458
- #
1459
- # key_management_client = Google::Cloud::Kms.new(version: :v1)
1460
- # formatted_name = Google::Cloud::Kms::V1::KeyManagementServiceClient.crypto_key_path("[PROJECT]", "[LOCATION]", "[KEY_RING]", "[CRYPTO_KEY]")
1461
- #
1462
- # # TODO: Initialize `crypto_key_version_id`:
1463
- # crypto_key_version_id = ''
1464
- # response = key_management_client.update_crypto_key_primary_version(formatted_name, crypto_key_version_id)
1465
-
1466
- def update_crypto_key_primary_version \
1467
- name,
1468
- crypto_key_version_id,
1469
- options: nil,
1470
- &block
1471
- req = {
1472
- name: name,
1473
- crypto_key_version_id: crypto_key_version_id
1474
- }.delete_if { |_, v| v.nil? }
1475
- req = Google::Gax::to_proto(req, Google::Cloud::Kms::V1::UpdateCryptoKeyPrimaryVersionRequest)
1476
- @update_crypto_key_primary_version.call(req, options, &block)
1477
- end
1478
-
1479
- # Schedule a {Google::Cloud::Kms::V1::CryptoKeyVersion CryptoKeyVersion} for destruction.
1480
- #
1481
- # Upon calling this method, {Google::Cloud::Kms::V1::CryptoKeyVersion#state CryptoKeyVersion#state} will be set to
1482
- # {Google::Cloud::Kms::V1::CryptoKeyVersion::CryptoKeyVersionState::DESTROY_SCHEDULED DESTROY_SCHEDULED}
1483
- # and {Google::Cloud::Kms::V1::CryptoKeyVersion#destroy_time destroy_time} will be set to a time 24
1484
- # hours in the future, at which point the {Google::Cloud::Kms::V1::CryptoKeyVersion#state state}
1485
- # will be changed to
1486
- # {Google::Cloud::Kms::V1::CryptoKeyVersion::CryptoKeyVersionState::DESTROYED DESTROYED}, and the key
1487
- # material will be irrevocably destroyed.
1488
- #
1489
- # Before the {Google::Cloud::Kms::V1::CryptoKeyVersion#destroy_time destroy_time} is reached,
1490
- # {Google::Cloud::Kms::V1::KeyManagementService::RestoreCryptoKeyVersion RestoreCryptoKeyVersion} may be called to reverse the process.
1491
- #
1492
- # @param name [String]
1493
- # Required. The resource name of the {Google::Cloud::Kms::V1::CryptoKeyVersion CryptoKeyVersion} to destroy.
1494
- # @param options [Google::Gax::CallOptions]
1495
- # Overrides the default settings for this call, e.g, timeout,
1496
- # retries, etc.
1497
- # @yield [result, operation] Access the result along with the RPC operation
1498
- # @yieldparam result [Google::Cloud::Kms::V1::CryptoKeyVersion]
1499
- # @yieldparam operation [GRPC::ActiveCall::Operation]
1500
- # @return [Google::Cloud::Kms::V1::CryptoKeyVersion]
1501
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
1502
- # @example
1503
- # require "google/cloud/kms"
1504
- #
1505
- # key_management_client = Google::Cloud::Kms.new(version: :v1)
1506
- # formatted_name = Google::Cloud::Kms::V1::KeyManagementServiceClient.crypto_key_version_path("[PROJECT]", "[LOCATION]", "[KEY_RING]", "[CRYPTO_KEY]", "[CRYPTO_KEY_VERSION]")
1507
- # response = key_management_client.destroy_crypto_key_version(formatted_name)
1508
-
1509
- def destroy_crypto_key_version \
1510
- name,
1511
- options: nil,
1512
- &block
1513
- req = {
1514
- name: name
1515
- }.delete_if { |_, v| v.nil? }
1516
- req = Google::Gax::to_proto(req, Google::Cloud::Kms::V1::DestroyCryptoKeyVersionRequest)
1517
- @destroy_crypto_key_version.call(req, options, &block)
1518
- end
1519
-
1520
- # Restore a {Google::Cloud::Kms::V1::CryptoKeyVersion CryptoKeyVersion} in the
1521
- # {Google::Cloud::Kms::V1::CryptoKeyVersion::CryptoKeyVersionState::DESTROY_SCHEDULED DESTROY_SCHEDULED}
1522
- # state.
1523
- #
1524
- # Upon restoration of the CryptoKeyVersion, {Google::Cloud::Kms::V1::CryptoKeyVersion#state state}
1525
- # will be set to {Google::Cloud::Kms::V1::CryptoKeyVersion::CryptoKeyVersionState::DISABLED DISABLED},
1526
- # and {Google::Cloud::Kms::V1::CryptoKeyVersion#destroy_time destroy_time} will be cleared.
1527
- #
1528
- # @param name [String]
1529
- # Required. The resource name of the {Google::Cloud::Kms::V1::CryptoKeyVersion CryptoKeyVersion} to restore.
1530
- # @param options [Google::Gax::CallOptions]
1531
- # Overrides the default settings for this call, e.g, timeout,
1532
- # retries, etc.
1533
- # @yield [result, operation] Access the result along with the RPC operation
1534
- # @yieldparam result [Google::Cloud::Kms::V1::CryptoKeyVersion]
1535
- # @yieldparam operation [GRPC::ActiveCall::Operation]
1536
- # @return [Google::Cloud::Kms::V1::CryptoKeyVersion]
1537
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
1538
- # @example
1539
- # require "google/cloud/kms"
1540
- #
1541
- # key_management_client = Google::Cloud::Kms.new(version: :v1)
1542
- # formatted_name = Google::Cloud::Kms::V1::KeyManagementServiceClient.crypto_key_version_path("[PROJECT]", "[LOCATION]", "[KEY_RING]", "[CRYPTO_KEY]", "[CRYPTO_KEY_VERSION]")
1543
- # response = key_management_client.restore_crypto_key_version(formatted_name)
1544
-
1545
- def restore_crypto_key_version \
1546
- name,
1547
- options: nil,
1548
- &block
1549
- req = {
1550
- name: name
1551
- }.delete_if { |_, v| v.nil? }
1552
- req = Google::Gax::to_proto(req, Google::Cloud::Kms::V1::RestoreCryptoKeyVersionRequest)
1553
- @restore_crypto_key_version.call(req, options, &block)
1554
- end
1555
-
1556
- # Returns the public key for the given {Google::Cloud::Kms::V1::CryptoKeyVersion CryptoKeyVersion}. The
1557
- # {Google::Cloud::Kms::V1::CryptoKey#purpose CryptoKey#purpose} must be
1558
- # {Google::Cloud::Kms::V1::CryptoKey::CryptoKeyPurpose::ASYMMETRIC_SIGN ASYMMETRIC_SIGN} or
1559
- # {Google::Cloud::Kms::V1::CryptoKey::CryptoKeyPurpose::ASYMMETRIC_DECRYPT ASYMMETRIC_DECRYPT}.
1560
- #
1561
- # @param name [String]
1562
- # Required. The {Google::Cloud::Kms::V1::CryptoKeyVersion#name name} of the {Google::Cloud::Kms::V1::CryptoKeyVersion CryptoKeyVersion} public key to
1563
- # get.
1564
- # @param options [Google::Gax::CallOptions]
1565
- # Overrides the default settings for this call, e.g, timeout,
1566
- # retries, etc.
1567
- # @yield [result, operation] Access the result along with the RPC operation
1568
- # @yieldparam result [Google::Cloud::Kms::V1::PublicKey]
1569
- # @yieldparam operation [GRPC::ActiveCall::Operation]
1570
- # @return [Google::Cloud::Kms::V1::PublicKey]
1571
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
1572
- # @example
1573
- # require "google/cloud/kms"
1574
- #
1575
- # key_management_client = Google::Cloud::Kms.new(version: :v1)
1576
- # formatted_name = Google::Cloud::Kms::V1::KeyManagementServiceClient.crypto_key_version_path("[PROJECT]", "[LOCATION]", "[KEY_RING]", "[CRYPTO_KEY]", "[CRYPTO_KEY_VERSION]")
1577
- # response = key_management_client.get_public_key(formatted_name)
1578
-
1579
- def get_public_key \
1580
- name,
1581
- options: nil,
1582
- &block
1583
- req = {
1584
- name: name
1585
- }.delete_if { |_, v| v.nil? }
1586
- req = Google::Gax::to_proto(req, Google::Cloud::Kms::V1::GetPublicKeyRequest)
1587
- @get_public_key.call(req, options, &block)
1588
- end
1589
-
1590
- # Decrypts data that was encrypted with a public key retrieved from
1591
- # {Google::Cloud::Kms::V1::KeyManagementService::GetPublicKey GetPublicKey} corresponding to a {Google::Cloud::Kms::V1::CryptoKeyVersion CryptoKeyVersion} with
1592
- # {Google::Cloud::Kms::V1::CryptoKey#purpose CryptoKey#purpose} ASYMMETRIC_DECRYPT.
1593
- #
1594
- # @param name [String]
1595
- # Required. The resource name of the {Google::Cloud::Kms::V1::CryptoKeyVersion CryptoKeyVersion} to use for
1596
- # decryption.
1597
- # @param ciphertext [String]
1598
- # Required. The data encrypted with the named {Google::Cloud::Kms::V1::CryptoKeyVersion CryptoKeyVersion}'s public
1599
- # key using OAEP.
1600
- # @param options [Google::Gax::CallOptions]
1601
- # Overrides the default settings for this call, e.g, timeout,
1602
- # retries, etc.
1603
- # @yield [result, operation] Access the result along with the RPC operation
1604
- # @yieldparam result [Google::Cloud::Kms::V1::AsymmetricDecryptResponse]
1605
- # @yieldparam operation [GRPC::ActiveCall::Operation]
1606
- # @return [Google::Cloud::Kms::V1::AsymmetricDecryptResponse]
1607
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
1608
- # @example
1609
- # require "google/cloud/kms"
1610
- #
1611
- # key_management_client = Google::Cloud::Kms.new(version: :v1)
1612
- # formatted_name = Google::Cloud::Kms::V1::KeyManagementServiceClient.crypto_key_version_path("[PROJECT]", "[LOCATION]", "[KEY_RING]", "[CRYPTO_KEY]", "[CRYPTO_KEY_VERSION]")
1613
- #
1614
- # # TODO: Initialize `ciphertext`:
1615
- # ciphertext = ''
1616
- # response = key_management_client.asymmetric_decrypt(formatted_name, ciphertext)
1617
-
1618
- def asymmetric_decrypt \
1619
- name,
1620
- ciphertext,
1621
- options: nil,
1622
- &block
1623
- req = {
1624
- name: name,
1625
- ciphertext: ciphertext
1626
- }.delete_if { |_, v| v.nil? }
1627
- req = Google::Gax::to_proto(req, Google::Cloud::Kms::V1::AsymmetricDecryptRequest)
1628
- @asymmetric_decrypt.call(req, options, &block)
1629
- end
1630
-
1631
- # Signs data using a {Google::Cloud::Kms::V1::CryptoKeyVersion CryptoKeyVersion} with {Google::Cloud::Kms::V1::CryptoKey#purpose CryptoKey#purpose}
1632
- # ASYMMETRIC_SIGN, producing a signature that can be verified with the public
1633
- # key retrieved from {Google::Cloud::Kms::V1::KeyManagementService::GetPublicKey GetPublicKey}.
1634
- #
1635
- # @param name [String]
1636
- # Required. The resource name of the {Google::Cloud::Kms::V1::CryptoKeyVersion CryptoKeyVersion} to use for signing.
1637
- # @param digest [Google::Cloud::Kms::V1::Digest | Hash]
1638
- # Required. The digest of the data to sign. The digest must be produced with
1639
- # the same digest algorithm as specified by the key version's
1640
- # {Google::Cloud::Kms::V1::CryptoKeyVersion#algorithm algorithm}.
1641
- # A hash of the same form as `Google::Cloud::Kms::V1::Digest`
1642
- # can also be provided.
1643
- # @param options [Google::Gax::CallOptions]
1644
- # Overrides the default settings for this call, e.g, timeout,
1645
- # retries, etc.
1646
- # @yield [result, operation] Access the result along with the RPC operation
1647
- # @yieldparam result [Google::Cloud::Kms::V1::AsymmetricSignResponse]
1648
- # @yieldparam operation [GRPC::ActiveCall::Operation]
1649
- # @return [Google::Cloud::Kms::V1::AsymmetricSignResponse]
1650
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
1651
- # @example
1652
- # require "google/cloud/kms"
1653
- #
1654
- # key_management_client = Google::Cloud::Kms.new(version: :v1)
1655
- # formatted_name = Google::Cloud::Kms::V1::KeyManagementServiceClient.crypto_key_version_path("[PROJECT]", "[LOCATION]", "[KEY_RING]", "[CRYPTO_KEY]", "[CRYPTO_KEY_VERSION]")
1656
- #
1657
- # # TODO: Initialize `digest`:
1658
- # digest = {}
1659
- # response = key_management_client.asymmetric_sign(formatted_name, digest)
1660
-
1661
- def asymmetric_sign \
1662
- name,
1663
- digest,
1664
- options: nil,
1665
- &block
1666
- req = {
1667
- name: name,
1668
- digest: digest
1669
- }.delete_if { |_, v| v.nil? }
1670
- req = Google::Gax::to_proto(req, Google::Cloud::Kms::V1::AsymmetricSignRequest)
1671
- @asymmetric_sign.call(req, options, &block)
1672
- end
1673
-
1674
- # Sets the access control policy on the specified resource. Replaces
1675
- # any existing policy.
1676
- #
1677
- # Can return Public Errors: NOT_FOUND, INVALID_ARGUMENT and
1678
- # PERMISSION_DENIED
1679
- #
1680
- # @param resource [String]
1681
- # REQUIRED: The resource for which the policy is being specified.
1682
- # See the operation documentation for the appropriate value for this field.
1683
- # @param policy [Google::Iam::V1::Policy | Hash]
1684
- # REQUIRED: The complete policy to be applied to the `resource`. The size of
1685
- # the policy is limited to a few 10s of KB. An empty policy is a
1686
- # valid policy but certain Cloud Platform services (such as Projects)
1687
- # might reject them.
1688
- # A hash of the same form as `Google::Iam::V1::Policy`
1689
- # can also be provided.
1690
- # @param options [Google::Gax::CallOptions]
1691
- # Overrides the default settings for this call, e.g, timeout,
1692
- # retries, etc.
1693
- # @yield [result, operation] Access the result along with the RPC operation
1694
- # @yieldparam result [Google::Iam::V1::Policy]
1695
- # @yieldparam operation [GRPC::ActiveCall::Operation]
1696
- # @return [Google::Iam::V1::Policy]
1697
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
1698
- # @example
1699
- # require "google/cloud/kms"
1700
- #
1701
- # key_management_client = Google::Cloud::Kms.new(version: :v1)
1702
- # formatted_resource = Google::Cloud::Kms::V1::KeyManagementServiceClient.key_ring_path("[PROJECT]", "[LOCATION]", "[KEY_RING]")
1703
- #
1704
- # # TODO: Initialize `policy`:
1705
- # policy = {}
1706
- # response = key_management_client.set_iam_policy(formatted_resource, policy)
1707
-
1708
- def set_iam_policy \
1709
- resource,
1710
- policy,
1711
- options: nil,
1712
- &block
1713
- req = {
1714
- resource: resource,
1715
- policy: policy
1716
- }.delete_if { |_, v| v.nil? }
1717
- req = Google::Gax::to_proto(req, Google::Iam::V1::SetIamPolicyRequest)
1718
- @set_iam_policy.call(req, options, &block)
1719
- end
1720
-
1721
- # Gets the access control policy for a resource. Returns an empty policy
1722
- # if the resource exists and does not have a policy set.
1723
- #
1724
- # @param resource [String]
1725
- # REQUIRED: The resource for which the policy is being requested.
1726
- # See the operation documentation for the appropriate value for this field.
1727
- # @param options_ [Google::Iam::V1::GetPolicyOptions | Hash]
1728
- # OPTIONAL: A `GetPolicyOptions` object for specifying options to
1729
- # `GetIamPolicy`. This field is only used by Cloud IAM.
1730
- # A hash of the same form as `Google::Iam::V1::GetPolicyOptions`
1731
- # can also be provided.
1732
- # @param options [Google::Gax::CallOptions]
1733
- # Overrides the default settings for this call, e.g, timeout,
1734
- # retries, etc.
1735
- # @yield [result, operation] Access the result along with the RPC operation
1736
- # @yieldparam result [Google::Iam::V1::Policy]
1737
- # @yieldparam operation [GRPC::ActiveCall::Operation]
1738
- # @return [Google::Iam::V1::Policy]
1739
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
1740
- # @example
1741
- # require "google/cloud/kms"
1742
- #
1743
- # key_management_client = Google::Cloud::Kms.new(version: :v1)
1744
- # formatted_resource = Google::Cloud::Kms::V1::KeyManagementServiceClient.key_ring_path("[PROJECT]", "[LOCATION]", "[KEY_RING]")
1745
- # response = key_management_client.get_iam_policy(formatted_resource)
1746
-
1747
- def get_iam_policy \
1748
- resource,
1749
- options_: nil,
1750
- options: nil,
1751
- &block
1752
- req = {
1753
- resource: resource,
1754
- options: options_
1755
- }.delete_if { |_, v| v.nil? }
1756
- req = Google::Gax::to_proto(req, Google::Iam::V1::GetIamPolicyRequest)
1757
- @get_iam_policy.call(req, options, &block)
1758
- end
1759
-
1760
- # Returns permissions that a caller has on the specified resource. If the
1761
- # resource does not exist, this will return an empty set of
1762
- # permissions, not a NOT_FOUND error.
1763
- #
1764
- # Note: This operation is designed to be used for building
1765
- # permission-aware UIs and command-line tools, not for authorization
1766
- # checking. This operation may "fail open" without warning.
1767
- #
1768
- # @param resource [String]
1769
- # REQUIRED: The resource for which the policy detail is being requested.
1770
- # See the operation documentation for the appropriate value for this field.
1771
- # @param permissions [Array<String>]
1772
- # The set of permissions to check for the `resource`. Permissions with
1773
- # wildcards (such as '*' or 'storage.*') are not allowed. For more
1774
- # information see
1775
- # [IAM Overview](https://cloud.google.com/iam/docs/overview#permissions).
1776
- # @param options [Google::Gax::CallOptions]
1777
- # Overrides the default settings for this call, e.g, timeout,
1778
- # retries, etc.
1779
- # @yield [result, operation] Access the result along with the RPC operation
1780
- # @yieldparam result [Google::Iam::V1::TestIamPermissionsResponse]
1781
- # @yieldparam operation [GRPC::ActiveCall::Operation]
1782
- # @return [Google::Iam::V1::TestIamPermissionsResponse]
1783
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
1784
- # @example
1785
- # require "google/cloud/kms"
1786
- #
1787
- # key_management_client = Google::Cloud::Kms.new(version: :v1)
1788
- # formatted_resource = Google::Cloud::Kms::V1::KeyManagementServiceClient.key_ring_path("[PROJECT]", "[LOCATION]", "[KEY_RING]")
1789
- #
1790
- # # TODO: Initialize `permissions`:
1791
- # permissions = []
1792
- # response = key_management_client.test_iam_permissions(formatted_resource, permissions)
1793
-
1794
- def test_iam_permissions \
1795
- resource,
1796
- permissions,
1797
- options: nil,
1798
- &block
1799
- req = {
1800
- resource: resource,
1801
- permissions: permissions
1802
- }.delete_if { |_, v| v.nil? }
1803
- req = Google::Gax::to_proto(req, Google::Iam::V1::TestIamPermissionsRequest)
1804
- @test_iam_permissions.call(req, options, &block)
1805
- end
1806
- end
1807
- end
1808
- end
1809
- end
1810
- end