google-cloud-kms 1.5.0 → 2.0.2

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