google-cloud-kms 1.6.0 → 2.0.0

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