Class: Google::Cloud::Kms::V1::KeyManagementService::Rest::Client

Inherits:
Object
  • Object
show all
Includes:
Paths
Defined in:
lib/google/cloud/kms/v1/key_management_service/rest/client.rb

Overview

REST client for the KeyManagementService service.

Google Cloud Key Management Service

Manages cryptographic keys and operations using those keys. Implements a REST model with the following objects:

If you are using manual gRPC libraries, see Using gRPC with Cloud KMS.

Defined Under Namespace

Classes: Configuration

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Paths

#crypto_key_path, #crypto_key_version_path, #import_job_path, #key_ring_path, #location_path

Constructor Details

#initialize {|config| ... } ⇒ Client

Create a new KeyManagementService REST client object.

Examples:


# Create a client using the default configuration
client = ::Google::Cloud::Kms::V1::KeyManagementService::Rest::Client.new

# Create a client using a custom configuration
client = ::Google::Cloud::Kms::V1::KeyManagementService::Rest::Client.new do |config|
  config.timeout = 10.0
end

Yields:

  • (config)

    Configure the KeyManagementService client.

Yield Parameters:



260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
# File 'lib/google/cloud/kms/v1/key_management_service/rest/client.rb', line 260

def initialize
  # Create the configuration object
  @config = Configuration.new Client.configure

  # Yield the configuration if needed
  yield @config if block_given?

  # Create credentials
  credentials = @config.credentials
  # Use self-signed JWT if the endpoint is unchanged from default,
  # but only if the default endpoint does not have a region prefix.
  enable_self_signed_jwt = @config.endpoint.nil? ||
                           (@config.endpoint == Configuration::DEFAULT_ENDPOINT &&
                           !@config.endpoint.split(".").first.include?("-"))
  credentials ||= Credentials.default scope: @config.scope,
                                      enable_self_signed_jwt: enable_self_signed_jwt
  if credentials.is_a?(::String) || credentials.is_a?(::Hash)
    credentials = Credentials.new credentials, scope: @config.scope
  end

  @quota_project_id = @config.quota_project
  @quota_project_id ||= credentials.quota_project_id if credentials.respond_to? :quota_project_id

  @key_management_service_stub = ::Google::Cloud::Kms::V1::KeyManagementService::Rest::ServiceStub.new(
    endpoint: @config.endpoint,
    endpoint_template: DEFAULT_ENDPOINT_TEMPLATE,
    universe_domain: @config.universe_domain,
    credentials: credentials
  )

  @location_client = Google::Cloud::Location::Locations::Rest::Client.new do |config|
    config.credentials = credentials
    config.quota_project = @quota_project_id
    config.endpoint = @key_management_service_stub.endpoint
    config.universe_domain = @key_management_service_stub.universe_domain
    config.bindings_override = @config.bindings_override
  end

  @iam_policy_client = Google::Iam::V1::IAMPolicy::Rest::Client.new do |config|
    config.credentials = credentials
    config.quota_project = @quota_project_id
    config.endpoint = @key_management_service_stub.endpoint
    config.universe_domain = @key_management_service_stub.universe_domain
    config.bindings_override = @config.bindings_override
  end
end

Instance Attribute Details

#iam_policy_clientGoogle::Iam::V1::IAMPolicy::Rest::Client (readonly)

Get the associated client for mix-in of the IAMPolicy.

Returns:

  • (Google::Iam::V1::IAMPolicy::Rest::Client)


319
320
321
# File 'lib/google/cloud/kms/v1/key_management_service/rest/client.rb', line 319

def iam_policy_client
  @iam_policy_client
end

#location_clientGoogle::Cloud::Location::Locations::Rest::Client (readonly)

Get the associated client for mix-in of the Locations.

Returns:

  • (Google::Cloud::Location::Locations::Rest::Client)


312
313
314
# File 'lib/google/cloud/kms/v1/key_management_service/rest/client.rb', line 312

def location_client
  @location_client
end

Class Method Details

.configure {|config| ... } ⇒ Client::Configuration

Configure the KeyManagementService Client class.

See Configuration for a description of the configuration fields.

Examples:


# Modify the configuration for all KeyManagementService clients
::Google::Cloud::Kms::V1::KeyManagementService::Rest::Client.configure do |config|
  config.timeout = 10.0
end

Yields:

  • (config)

    Configure the Client client.

Yield Parameters:

Returns:



74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
# File 'lib/google/cloud/kms/v1/key_management_service/rest/client.rb', line 74

def self.configure
  @configure ||= begin
    namespace = ["Google", "Cloud", "Kms", "V1"]
    parent_config = while namespace.any?
                      parent_name = namespace.join "::"
                      parent_const = const_get parent_name
                      break parent_const.configure if parent_const.respond_to? :configure
                      namespace.pop
                    end
    default_config = Client::Configuration.new parent_config

    default_config.rpcs.list_key_rings.timeout = 60.0
    default_config.rpcs.list_key_rings.retry_policy = {
      initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [14, 4]
    }

    default_config.rpcs.list_crypto_keys.timeout = 60.0
    default_config.rpcs.list_crypto_keys.retry_policy = {
      initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [14, 4]
    }

    default_config.rpcs.list_crypto_key_versions.timeout = 60.0
    default_config.rpcs.list_crypto_key_versions.retry_policy = {
      initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [14, 4]
    }

    default_config.rpcs.list_import_jobs.timeout = 60.0
    default_config.rpcs.list_import_jobs.retry_policy = {
      initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [14, 4]
    }

    default_config.rpcs.get_key_ring.timeout = 60.0
    default_config.rpcs.get_key_ring.retry_policy = {
      initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [14, 4]
    }

    default_config.rpcs.get_crypto_key.timeout = 60.0
    default_config.rpcs.get_crypto_key.retry_policy = {
      initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [14, 4]
    }

    default_config.rpcs.get_crypto_key_version.timeout = 60.0
    default_config.rpcs.get_crypto_key_version.retry_policy = {
      initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [14, 4]
    }

    default_config.rpcs.get_public_key.timeout = 60.0
    default_config.rpcs.get_public_key.retry_policy = {
      initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [14, 4]
    }

    default_config.rpcs.get_import_job.timeout = 60.0
    default_config.rpcs.get_import_job.retry_policy = {
      initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [14, 4]
    }

    default_config.rpcs.create_key_ring.timeout = 60.0
    default_config.rpcs.create_key_ring.retry_policy = {
      initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [14, 4]
    }

    default_config.rpcs.create_crypto_key.timeout = 60.0
    default_config.rpcs.create_crypto_key.retry_policy = {
      initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [14, 4]
    }

    default_config.rpcs.create_crypto_key_version.timeout = 60.0

    default_config.rpcs.import_crypto_key_version.timeout = 60.0

    default_config.rpcs.create_import_job.timeout = 60.0
    default_config.rpcs.create_import_job.retry_policy = {
      initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [14, 4]
    }

    default_config.rpcs.update_crypto_key.timeout = 60.0
    default_config.rpcs.update_crypto_key.retry_policy = {
      initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [14, 4]
    }

    default_config.rpcs.update_crypto_key_version.timeout = 60.0
    default_config.rpcs.update_crypto_key_version.retry_policy = {
      initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [14, 4]
    }

    default_config.rpcs.update_crypto_key_primary_version.timeout = 60.0
    default_config.rpcs.update_crypto_key_primary_version.retry_policy = {
      initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [14, 4]
    }

    default_config.rpcs.destroy_crypto_key_version.timeout = 60.0
    default_config.rpcs.destroy_crypto_key_version.retry_policy = {
      initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [14, 4]
    }

    default_config.rpcs.restore_crypto_key_version.timeout = 60.0
    default_config.rpcs.restore_crypto_key_version.retry_policy = {
      initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [14, 4]
    }

    default_config.rpcs.encrypt.timeout = 60.0
    default_config.rpcs.encrypt.retry_policy = {
      initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [14, 4]
    }

    default_config.rpcs.decrypt.timeout = 60.0
    default_config.rpcs.decrypt.retry_policy = {
      initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [14, 4]
    }

    default_config.rpcs.asymmetric_sign.timeout = 60.0
    default_config.rpcs.asymmetric_sign.retry_policy = {
      initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [14, 4]
    }

    default_config.rpcs.asymmetric_decrypt.timeout = 60.0
    default_config.rpcs.asymmetric_decrypt.retry_policy = {
      initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [14, 4]
    }

    default_config.rpcs.mac_sign.timeout = 60.0
    default_config.rpcs.mac_sign.retry_policy = {
      initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [14, 4]
    }

    default_config.rpcs.mac_verify.timeout = 60.0
    default_config.rpcs.mac_verify.retry_policy = {
      initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [14, 4]
    }

    default_config.rpcs.generate_random_bytes.timeout = 60.0
    default_config.rpcs.generate_random_bytes.retry_policy = {
      initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [14, 4]
    }

    default_config
  end
  yield @configure if block_given?
  @configure
end

Instance Method Details

#asymmetric_decrypt(request, options = nil) ⇒ ::Google::Cloud::Kms::V1::AsymmetricDecryptResponse #asymmetric_decrypt(name: nil, ciphertext: nil, ciphertext_crc32c: nil) ⇒ ::Google::Cloud::Kms::V1::AsymmetricDecryptResponse

Decrypts data that was encrypted with a public key retrieved from GetPublicKey corresponding to a CryptoKeyVersion with CryptoKey.purpose ASYMMETRIC_DECRYPT.

Examples:

Basic example

require "google/cloud/kms/v1"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Kms::V1::KeyManagementService::Rest::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Kms::V1::AsymmetricDecryptRequest.new

# Call the asymmetric_decrypt method.
result = client.asymmetric_decrypt request

# The returned object is of type Google::Cloud::Kms::V1::AsymmetricDecryptResponse.
p result

Overloads:

  • #asymmetric_decrypt(request, options = nil) ⇒ ::Google::Cloud::Kms::V1::AsymmetricDecryptResponse

    Pass arguments to asymmetric_decrypt via a request object, either of type AsymmetricDecryptRequest or an equivalent Hash.

    Parameters:

    • request (::Google::Cloud::Kms::V1::AsymmetricDecryptRequest, ::Hash)

      A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.

    • options (::Gapic::CallOptions, ::Hash) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries etc. Optional.

  • #asymmetric_decrypt(name: nil, ciphertext: nil, ciphertext_crc32c: nil) ⇒ ::Google::Cloud::Kms::V1::AsymmetricDecryptResponse

    Pass arguments to asymmetric_decrypt via keyword arguments. Note that at least one keyword argument is required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash as a request object (see above).

    Parameters:

Yields:

  • (result, operation)

    Access the result along with the TransportOperation object

Yield Parameters:

Returns:

Raises:

  • (::Google::Cloud::Error)

    if the REST call is aborted.



2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
# File 'lib/google/cloud/kms/v1/key_management_service/rest/client.rb', line 2930

def asymmetric_decrypt request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Kms::V1::AsymmetricDecryptRequest

  # Converts hash and nil to an options object
  options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h

  # Customize the options with defaults
   = @config.rpcs.asymmetric_decrypt..to_h

  # Set x-goog-api-client and x-goog-user-project headers
  [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
    lib_name: @config.lib_name, lib_version: @config.lib_version,
    gapic_version: ::Google::Cloud::Kms::V1::VERSION,
    transports_version_send: [:rest]

  [:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  options.apply_defaults timeout:      @config.rpcs.asymmetric_decrypt.timeout,
                         metadata:     ,
                         retry_policy: @config.rpcs.asymmetric_decrypt.retry_policy

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.,
                         retry_policy: @config.retry_policy

  @key_management_service_stub.asymmetric_decrypt request, options do |result, operation|
    yield result, operation if block_given?
    return result
  end
rescue ::Gapic::Rest::Error => e
  raise ::Google::Cloud::Error.from_error(e)
end

#asymmetric_sign(request, options = nil) ⇒ ::Google::Cloud::Kms::V1::AsymmetricSignResponse #asymmetric_sign(name: nil, digest: nil, digest_crc32c: nil, data: nil, data_crc32c: nil) ⇒ ::Google::Cloud::Kms::V1::AsymmetricSignResponse

Signs data using a CryptoKeyVersion with CryptoKey.purpose ASYMMETRIC_SIGN, producing a signature that can be verified with the public key retrieved from GetPublicKey.

Examples:

Basic example

require "google/cloud/kms/v1"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Kms::V1::KeyManagementService::Rest::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Kms::V1::AsymmetricSignRequest.new

# Call the asymmetric_sign method.
result = client.asymmetric_sign request

# The returned object is of type Google::Cloud::Kms::V1::AsymmetricSignResponse.
p result

Overloads:

  • #asymmetric_sign(request, options = nil) ⇒ ::Google::Cloud::Kms::V1::AsymmetricSignResponse

    Pass arguments to asymmetric_sign via a request object, either of type AsymmetricSignRequest or an equivalent Hash.

    Parameters:

    • request (::Google::Cloud::Kms::V1::AsymmetricSignRequest, ::Hash)

      A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.

    • options (::Gapic::CallOptions, ::Hash) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries etc. Optional.

  • #asymmetric_sign(name: nil, digest: nil, digest_crc32c: nil, data: nil, data_crc32c: nil) ⇒ ::Google::Cloud::Kms::V1::AsymmetricSignResponse

    Pass arguments to asymmetric_sign via keyword arguments. Note that at least one keyword argument is required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash as a request object (see above).

    Parameters:

Yields:

  • (result, operation)

    Access the result along with the TransportOperation object

Yield Parameters:

Returns:

Raises:

  • (::Google::Cloud::Error)

    if the REST call is aborted.



2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
# File 'lib/google/cloud/kms/v1/key_management_service/rest/client.rb', line 2822

def asymmetric_sign request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Kms::V1::AsymmetricSignRequest

  # Converts hash and nil to an options object
  options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h

  # Customize the options with defaults
   = @config.rpcs.asymmetric_sign..to_h

  # Set x-goog-api-client and x-goog-user-project headers
  [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
    lib_name: @config.lib_name, lib_version: @config.lib_version,
    gapic_version: ::Google::Cloud::Kms::V1::VERSION,
    transports_version_send: [:rest]

  [:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  options.apply_defaults timeout:      @config.rpcs.asymmetric_sign.timeout,
                         metadata:     ,
                         retry_policy: @config.rpcs.asymmetric_sign.retry_policy

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.,
                         retry_policy: @config.retry_policy

  @key_management_service_stub.asymmetric_sign request, options do |result, operation|
    yield result, operation if block_given?
    return result
  end
rescue ::Gapic::Rest::Error => e
  raise ::Google::Cloud::Error.from_error(e)
end

#configure {|config| ... } ⇒ Client::Configuration

Configure the KeyManagementService Client instance.

The configuration is set to the derived mode, meaning that values can be changed, but structural changes (adding new fields, etc.) are not allowed. Structural changes should be made on configure.

See Configuration for a description of the configuration fields.

Yields:

  • (config)

    Configure the Client client.

Yield Parameters:

Returns:



230
231
232
233
# File 'lib/google/cloud/kms/v1/key_management_service/rest/client.rb', line 230

def configure
  yield @config if block_given?
  @config
end

#create_crypto_key(request, options = nil) ⇒ ::Google::Cloud::Kms::V1::CryptoKey #create_crypto_key(parent: nil, crypto_key_id: nil, crypto_key: nil, skip_initial_version_creation: nil) ⇒ ::Google::Cloud::Kms::V1::CryptoKey

Create a new CryptoKey within a KeyRing.

CryptoKey.purpose and CryptoKey.version_template.algorithm are required.

Examples:

Basic example

require "google/cloud/kms/v1"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Kms::V1::KeyManagementService::Rest::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Kms::V1::CreateCryptoKeyRequest.new

# Call the create_crypto_key method.
result = client.create_crypto_key request

# The returned object is of type Google::Cloud::Kms::V1::CryptoKey.
p result

Overloads:

  • #create_crypto_key(request, options = nil) ⇒ ::Google::Cloud::Kms::V1::CryptoKey

    Pass arguments to create_crypto_key via a request object, either of type CreateCryptoKeyRequest or an equivalent Hash.

    Parameters:

    • request (::Google::Cloud::Kms::V1::CreateCryptoKeyRequest, ::Hash)

      A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.

    • options (::Gapic::CallOptions, ::Hash) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries etc. Optional.

  • #create_crypto_key(parent: nil, crypto_key_id: nil, crypto_key: nil, skip_initial_version_creation: nil) ⇒ ::Google::Cloud::Kms::V1::CryptoKey

    Pass arguments to create_crypto_key via keyword arguments. Note that at least one keyword argument is required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash as a request object (see above).

    Parameters:

Yields:

  • (result, operation)

    Access the result along with the TransportOperation object

Yield Parameters:

Returns:

Raises:

  • (::Google::Cloud::Error)

    if the REST call is aborted.



1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
# File 'lib/google/cloud/kms/v1/key_management_service/rest/client.rb', line 1303

def create_crypto_key request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Kms::V1::CreateCryptoKeyRequest

  # Converts hash and nil to an options object
  options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h

  # Customize the options with defaults
   = @config.rpcs.create_crypto_key..to_h

  # Set x-goog-api-client and x-goog-user-project headers
  [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
    lib_name: @config.lib_name, lib_version: @config.lib_version,
    gapic_version: ::Google::Cloud::Kms::V1::VERSION,
    transports_version_send: [:rest]

  [:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  options.apply_defaults timeout:      @config.rpcs.create_crypto_key.timeout,
                         metadata:     ,
                         retry_policy: @config.rpcs.create_crypto_key.retry_policy

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.,
                         retry_policy: @config.retry_policy

  @key_management_service_stub.create_crypto_key request, options do |result, operation|
    yield result, operation if block_given?
    return result
  end
rescue ::Gapic::Rest::Error => e
  raise ::Google::Cloud::Error.from_error(e)
end

#create_crypto_key_version(request, options = nil) ⇒ ::Google::Cloud::Kms::V1::CryptoKeyVersion #create_crypto_key_version(parent: nil, crypto_key_version: nil) ⇒ ::Google::Cloud::Kms::V1::CryptoKeyVersion

Create a new CryptoKeyVersion in a CryptoKey.

The server will assign the next sequential id. If unset, state will be set to ENABLED.

Examples:

Basic example

require "google/cloud/kms/v1"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Kms::V1::KeyManagementService::Rest::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Kms::V1::CreateCryptoKeyVersionRequest.new

# Call the create_crypto_key_version method.
result = client.create_crypto_key_version request

# The returned object is of type Google::Cloud::Kms::V1::CryptoKeyVersion.
p result

Overloads:

Yields:

  • (result, operation)

    Access the result along with the TransportOperation object

Yield Parameters:

Returns:

Raises:

  • (::Google::Cloud::Error)

    if the REST call is aborted.



1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
# File 'lib/google/cloud/kms/v1/key_management_service/rest/client.rb', line 1391

def create_crypto_key_version request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Kms::V1::CreateCryptoKeyVersionRequest

  # Converts hash and nil to an options object
  options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h

  # Customize the options with defaults
   = @config.rpcs.create_crypto_key_version..to_h

  # Set x-goog-api-client and x-goog-user-project headers
  [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
    lib_name: @config.lib_name, lib_version: @config.lib_version,
    gapic_version: ::Google::Cloud::Kms::V1::VERSION,
    transports_version_send: [:rest]

  [:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  options.apply_defaults timeout:      @config.rpcs.create_crypto_key_version.timeout,
                         metadata:     ,
                         retry_policy: @config.rpcs.create_crypto_key_version.retry_policy

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.,
                         retry_policy: @config.retry_policy

  @key_management_service_stub.create_crypto_key_version request, options do |result, operation|
    yield result, operation if block_given?
    return result
  end
rescue ::Gapic::Rest::Error => e
  raise ::Google::Cloud::Error.from_error(e)
end

#create_import_job(request, options = nil) ⇒ ::Google::Cloud::Kms::V1::ImportJob #create_import_job(parent: nil, import_job_id: nil, import_job: nil) ⇒ ::Google::Cloud::Kms::V1::ImportJob

Create a new ImportJob within a KeyRing.

ImportJob.import_method is required.

Examples:

Basic example

require "google/cloud/kms/v1"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Kms::V1::KeyManagementService::Rest::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Kms::V1::CreateImportJobRequest.new

# Call the create_import_job method.
result = client.create_import_job request

# The returned object is of type Google::Cloud::Kms::V1::ImportJob.
p result

Overloads:

  • #create_import_job(request, options = nil) ⇒ ::Google::Cloud::Kms::V1::ImportJob

    Pass arguments to create_import_job via a request object, either of type CreateImportJobRequest or an equivalent Hash.

    Parameters:

    • request (::Google::Cloud::Kms::V1::CreateImportJobRequest, ::Hash)

      A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.

    • options (::Gapic::CallOptions, ::Hash) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries etc. Optional.

  • #create_import_job(parent: nil, import_job_id: nil, import_job: nil) ⇒ ::Google::Cloud::Kms::V1::ImportJob

    Pass arguments to create_import_job via keyword arguments. Note that at least one keyword argument is required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash as a request object (see above).

    Parameters:

    • parent (::String) (defaults to: nil)

      Required. The name of the KeyRing associated with the ImportJobs.

    • import_job_id (::String) (defaults to: nil)

      Required. It must be unique within a KeyRing and match the regular expression [a-zA-Z0-9_-]{1,63}

    • import_job (::Google::Cloud::Kms::V1::ImportJob, ::Hash) (defaults to: nil)

      Required. An ImportJob with initial field values.

Yields:

  • (result, operation)

    Access the result along with the TransportOperation object

Yield Parameters:

Returns:

Raises:

  • (::Google::Cloud::Error)

    if the REST call is aborted.



1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
# File 'lib/google/cloud/kms/v1/key_management_service/rest/client.rb', line 1646

def create_import_job request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Kms::V1::CreateImportJobRequest

  # Converts hash and nil to an options object
  options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h

  # Customize the options with defaults
   = @config.rpcs.create_import_job..to_h

  # Set x-goog-api-client and x-goog-user-project headers
  [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
    lib_name: @config.lib_name, lib_version: @config.lib_version,
    gapic_version: ::Google::Cloud::Kms::V1::VERSION,
    transports_version_send: [:rest]

  [:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  options.apply_defaults timeout:      @config.rpcs.create_import_job.timeout,
                         metadata:     ,
                         retry_policy: @config.rpcs.create_import_job.retry_policy

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.,
                         retry_policy: @config.retry_policy

  @key_management_service_stub.create_import_job request, options do |result, operation|
    yield result, operation if block_given?
    return result
  end
rescue ::Gapic::Rest::Error => e
  raise ::Google::Cloud::Error.from_error(e)
end

#create_key_ring(request, options = nil) ⇒ ::Google::Cloud::Kms::V1::KeyRing #create_key_ring(parent: nil, key_ring_id: nil, key_ring: nil) ⇒ ::Google::Cloud::Kms::V1::KeyRing

Create a new KeyRing in a given Project and Location.

Examples:

Basic example

require "google/cloud/kms/v1"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Kms::V1::KeyManagementService::Rest::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Kms::V1::CreateKeyRingRequest.new

# Call the create_key_ring method.
result = client.create_key_ring request

# The returned object is of type Google::Cloud::Kms::V1::KeyRing.
p result

Overloads:

  • #create_key_ring(request, options = nil) ⇒ ::Google::Cloud::Kms::V1::KeyRing

    Pass arguments to create_key_ring via a request object, either of type CreateKeyRingRequest or an equivalent Hash.

    Parameters:

    • request (::Google::Cloud::Kms::V1::CreateKeyRingRequest, ::Hash)

      A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.

    • options (::Gapic::CallOptions, ::Hash) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries etc. Optional.

  • #create_key_ring(parent: nil, key_ring_id: nil, key_ring: nil) ⇒ ::Google::Cloud::Kms::V1::KeyRing

    Pass arguments to create_key_ring via keyword arguments. Note that at least one keyword argument is required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash as a request object (see above).

    Parameters:

    • parent (::String) (defaults to: nil)

      Required. The resource name of the location associated with the KeyRings, in the format projects/*/locations/*.

    • key_ring_id (::String) (defaults to: nil)

      Required. It must be unique within a location and match the regular expression [a-zA-Z0-9_-]{1,63}

    • key_ring (::Google::Cloud::Kms::V1::KeyRing, ::Hash) (defaults to: nil)

      Required. A KeyRing with initial field values.

Yields:

  • (result, operation)

    Access the result along with the TransportOperation object

Yield Parameters:

Returns:

Raises:

  • (::Google::Cloud::Error)

    if the REST call is aborted.



1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
# File 'lib/google/cloud/kms/v1/key_management_service/rest/client.rb', line 1204

def create_key_ring request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Kms::V1::CreateKeyRingRequest

  # Converts hash and nil to an options object
  options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h

  # Customize the options with defaults
   = @config.rpcs.create_key_ring..to_h

  # Set x-goog-api-client and x-goog-user-project headers
  [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
    lib_name: @config.lib_name, lib_version: @config.lib_version,
    gapic_version: ::Google::Cloud::Kms::V1::VERSION,
    transports_version_send: [:rest]

  [:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  options.apply_defaults timeout:      @config.rpcs.create_key_ring.timeout,
                         metadata:     ,
                         retry_policy: @config.rpcs.create_key_ring.retry_policy

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.,
                         retry_policy: @config.retry_policy

  @key_management_service_stub.create_key_ring request, options do |result, operation|
    yield result, operation if block_given?
    return result
  end
rescue ::Gapic::Rest::Error => e
  raise ::Google::Cloud::Error.from_error(e)
end

#decrypt(request, options = nil) ⇒ ::Google::Cloud::Kms::V1::DecryptResponse #decrypt(name: nil, ciphertext: nil, additional_authenticated_data: nil, ciphertext_crc32c: nil, additional_authenticated_data_crc32c: nil) ⇒ ::Google::Cloud::Kms::V1::DecryptResponse

Decrypts data that was protected by Encrypt. The CryptoKey.purpose must be ENCRYPT_DECRYPT.

Examples:

Basic example

require "google/cloud/kms/v1"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Kms::V1::KeyManagementService::Rest::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Kms::V1::DecryptRequest.new

# Call the decrypt method.
result = client.decrypt request

# The returned object is of type Google::Cloud::Kms::V1::DecryptResponse.
p result

Overloads:

  • #decrypt(request, options = nil) ⇒ ::Google::Cloud::Kms::V1::DecryptResponse

    Pass arguments to decrypt via a request object, either of type DecryptRequest or an equivalent Hash.

    Parameters:

    • request (::Google::Cloud::Kms::V1::DecryptRequest, ::Hash)

      A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.

    • options (::Gapic::CallOptions, ::Hash) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries etc. Optional.

  • #decrypt(name: nil, ciphertext: nil, additional_authenticated_data: nil, ciphertext_crc32c: nil, additional_authenticated_data_crc32c: nil) ⇒ ::Google::Cloud::Kms::V1::DecryptResponse

    Pass arguments to decrypt via keyword arguments. Note that at least one keyword argument is required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash as a request object (see above).

    Parameters:

Yields:

  • (result, operation)

    Access the result along with the TransportOperation object

Yield Parameters:

Returns:

Raises:

  • (::Google::Cloud::Error)

    if the REST call is aborted.



2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
# File 'lib/google/cloud/kms/v1/key_management_service/rest/client.rb', line 2373

def decrypt request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Kms::V1::DecryptRequest

  # Converts hash and nil to an options object
  options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h

  # Customize the options with defaults
   = @config.rpcs.decrypt..to_h

  # Set x-goog-api-client and x-goog-user-project headers
  [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
    lib_name: @config.lib_name, lib_version: @config.lib_version,
    gapic_version: ::Google::Cloud::Kms::V1::VERSION,
    transports_version_send: [:rest]

  [:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  options.apply_defaults timeout:      @config.rpcs.decrypt.timeout,
                         metadata:     ,
                         retry_policy: @config.rpcs.decrypt.retry_policy

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.,
                         retry_policy: @config.retry_policy

  @key_management_service_stub.decrypt request, options do |result, operation|
    yield result, operation if block_given?
    return result
  end
rescue ::Gapic::Rest::Error => e
  raise ::Google::Cloud::Error.from_error(e)
end

#destroy_crypto_key_version(request, options = nil) ⇒ ::Google::Cloud::Kms::V1::CryptoKeyVersion #destroy_crypto_key_version(name: nil) ⇒ ::Google::Cloud::Kms::V1::CryptoKeyVersion

Schedule a CryptoKeyVersion for destruction.

Upon calling this method, CryptoKeyVersion.state will be set to DESTROY_SCHEDULED, and destroy_time will be set to the time destroy_scheduled_duration in the future. At that time, the state will automatically change to DESTROYED, and the key material will be irrevocably destroyed.

Before the destroy_time is reached, RestoreCryptoKeyVersion may be called to reverse the process.

Examples:

Basic example

require "google/cloud/kms/v1"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Kms::V1::KeyManagementService::Rest::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Kms::V1::DestroyCryptoKeyVersionRequest.new

# Call the destroy_crypto_key_version method.
result = client.destroy_crypto_key_version request

# The returned object is of type Google::Cloud::Kms::V1::CryptoKeyVersion.
p result

Overloads:

  • #destroy_crypto_key_version(request, options = nil) ⇒ ::Google::Cloud::Kms::V1::CryptoKeyVersion

    Pass arguments to destroy_crypto_key_version via a request object, either of type DestroyCryptoKeyVersionRequest or an equivalent Hash.

    Parameters:

    • request (::Google::Cloud::Kms::V1::DestroyCryptoKeyVersionRequest, ::Hash)

      A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.

    • options (::Gapic::CallOptions, ::Hash) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries etc. Optional.

  • #destroy_crypto_key_version(name: nil) ⇒ ::Google::Cloud::Kms::V1::CryptoKeyVersion

    Pass arguments to destroy_crypto_key_version via keyword arguments. Note that at least one keyword argument is required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash as a request object (see above).

    Parameters:

    • name (::String) (defaults to: nil)

      Required. The resource name of the CryptoKeyVersion to destroy.

Yields:

  • (result, operation)

    Access the result along with the TransportOperation object

Yield Parameters:

Returns:

Raises:

  • (::Google::Cloud::Error)

    if the REST call is aborted.



2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
# File 'lib/google/cloud/kms/v1/key_management_service/rest/client.rb', line 2004

def destroy_crypto_key_version request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Kms::V1::DestroyCryptoKeyVersionRequest

  # Converts hash and nil to an options object
  options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h

  # Customize the options with defaults
   = @config.rpcs.destroy_crypto_key_version..to_h

  # Set x-goog-api-client and x-goog-user-project headers
  [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
    lib_name: @config.lib_name, lib_version: @config.lib_version,
    gapic_version: ::Google::Cloud::Kms::V1::VERSION,
    transports_version_send: [:rest]

  [:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  options.apply_defaults timeout:      @config.rpcs.destroy_crypto_key_version.timeout,
                         metadata:     ,
                         retry_policy: @config.rpcs.destroy_crypto_key_version.retry_policy

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.,
                         retry_policy: @config.retry_policy

  @key_management_service_stub.destroy_crypto_key_version request, options do |result, operation|
    yield result, operation if block_given?
    return result
  end
rescue ::Gapic::Rest::Error => e
  raise ::Google::Cloud::Error.from_error(e)
end

#encrypt(request, options = nil) ⇒ ::Google::Cloud::Kms::V1::EncryptResponse #encrypt(name: nil, plaintext: nil, additional_authenticated_data: nil, plaintext_crc32c: nil, additional_authenticated_data_crc32c: nil) ⇒ ::Google::Cloud::Kms::V1::EncryptResponse

Encrypts data, so that it can only be recovered by a call to Decrypt. The CryptoKey.purpose must be ENCRYPT_DECRYPT.

Examples:

Basic example

require "google/cloud/kms/v1"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Kms::V1::KeyManagementService::Rest::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Kms::V1::EncryptRequest.new

# Call the encrypt method.
result = client.encrypt request

# The returned object is of type Google::Cloud::Kms::V1::EncryptResponse.
p result

Overloads:

  • #encrypt(request, options = nil) ⇒ ::Google::Cloud::Kms::V1::EncryptResponse

    Pass arguments to encrypt via a request object, either of type EncryptRequest or an equivalent Hash.

    Parameters:

    • request (::Google::Cloud::Kms::V1::EncryptRequest, ::Hash)

      A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.

    • options (::Gapic::CallOptions, ::Hash) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries etc. Optional.

  • #encrypt(name: nil, plaintext: nil, additional_authenticated_data: nil, plaintext_crc32c: nil, additional_authenticated_data_crc32c: nil) ⇒ ::Google::Cloud::Kms::V1::EncryptResponse

    Pass arguments to encrypt via keyword arguments. Note that at least one keyword argument is required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash as a request object (see above).

    Parameters:

Yields:

  • (result, operation)

    Access the result along with the TransportOperation object

Yield Parameters:

Returns:

Raises:

  • (::Google::Cloud::Error)

    if the REST call is aborted.



2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
# File 'lib/google/cloud/kms/v1/key_management_service/rest/client.rb', line 2244

def encrypt request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Kms::V1::EncryptRequest

  # Converts hash and nil to an options object
  options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h

  # Customize the options with defaults
   = @config.rpcs.encrypt..to_h

  # Set x-goog-api-client and x-goog-user-project headers
  [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
    lib_name: @config.lib_name, lib_version: @config.lib_version,
    gapic_version: ::Google::Cloud::Kms::V1::VERSION,
    transports_version_send: [:rest]

  [:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  options.apply_defaults timeout:      @config.rpcs.encrypt.timeout,
                         metadata:     ,
                         retry_policy: @config.rpcs.encrypt.retry_policy

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.,
                         retry_policy: @config.retry_policy

  @key_management_service_stub.encrypt request, options do |result, operation|
    yield result, operation if block_given?
    return result
  end
rescue ::Gapic::Rest::Error => e
  raise ::Google::Cloud::Error.from_error(e)
end

#generate_random_bytes(request, options = nil) ⇒ ::Google::Cloud::Kms::V1::GenerateRandomBytesResponse #generate_random_bytes(location: nil, length_bytes: nil, protection_level: nil) ⇒ ::Google::Cloud::Kms::V1::GenerateRandomBytesResponse

Generate random bytes using the Cloud KMS randomness source in the provided location.

Examples:

Basic example

require "google/cloud/kms/v1"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Kms::V1::KeyManagementService::Rest::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Kms::V1::GenerateRandomBytesRequest.new

# Call the generate_random_bytes method.
result = client.generate_random_bytes request

# The returned object is of type Google::Cloud::Kms::V1::GenerateRandomBytesResponse.
p result

Overloads:

  • #generate_random_bytes(request, options = nil) ⇒ ::Google::Cloud::Kms::V1::GenerateRandomBytesResponse

    Pass arguments to generate_random_bytes via a request object, either of type GenerateRandomBytesRequest or an equivalent Hash.

    Parameters:

    • request (::Google::Cloud::Kms::V1::GenerateRandomBytesRequest, ::Hash)

      A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.

    • options (::Gapic::CallOptions, ::Hash) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries etc. Optional.

  • #generate_random_bytes(location: nil, length_bytes: nil, protection_level: nil) ⇒ ::Google::Cloud::Kms::V1::GenerateRandomBytesResponse

    Pass arguments to generate_random_bytes via keyword arguments. Note that at least one keyword argument is required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash as a request object (see above).

    Parameters:

    • location (::String) (defaults to: nil)

      The project-specific location in which to generate random bytes. For example, "projects/my-project/locations/us-central1".

    • length_bytes (::Integer) (defaults to: nil)

      The length in bytes of the amount of randomness to retrieve. Minimum 8 bytes, maximum 1024 bytes.

    • protection_level (::Google::Cloud::Kms::V1::ProtectionLevel) (defaults to: nil)

      The ProtectionLevel to use when generating the random data. Currently, only HSM protection level is supported.

Yields:

  • (result, operation)

    Access the result along with the TransportOperation object

Yield Parameters:

Returns:

Raises:

  • (::Google::Cloud::Error)

    if the REST call is aborted.



3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
# File 'lib/google/cloud/kms/v1/key_management_service/rest/client.rb', line 3246

def generate_random_bytes request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Kms::V1::GenerateRandomBytesRequest

  # Converts hash and nil to an options object
  options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h

  # Customize the options with defaults
   = @config.rpcs.generate_random_bytes..to_h

  # Set x-goog-api-client and x-goog-user-project headers
  [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
    lib_name: @config.lib_name, lib_version: @config.lib_version,
    gapic_version: ::Google::Cloud::Kms::V1::VERSION,
    transports_version_send: [:rest]

  [:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  options.apply_defaults timeout:      @config.rpcs.generate_random_bytes.timeout,
                         metadata:     ,
                         retry_policy: @config.rpcs.generate_random_bytes.retry_policy

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.,
                         retry_policy: @config.retry_policy

  @key_management_service_stub.generate_random_bytes request, options do |result, operation|
    yield result, operation if block_given?
    return result
  end
rescue ::Gapic::Rest::Error => e
  raise ::Google::Cloud::Error.from_error(e)
end

#get_crypto_key(request, options = nil) ⇒ ::Google::Cloud::Kms::V1::CryptoKey #get_crypto_key(name: nil) ⇒ ::Google::Cloud::Kms::V1::CryptoKey

Returns metadata for a given CryptoKey, as well as its primary CryptoKeyVersion.

Examples:

Basic example

require "google/cloud/kms/v1"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Kms::V1::KeyManagementService::Rest::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Kms::V1::GetCryptoKeyRequest.new

# Call the get_crypto_key method.
result = client.get_crypto_key request

# The returned object is of type Google::Cloud::Kms::V1::CryptoKey.
p result

Overloads:

  • #get_crypto_key(request, options = nil) ⇒ ::Google::Cloud::Kms::V1::CryptoKey

    Pass arguments to get_crypto_key via a request object, either of type GetCryptoKeyRequest or an equivalent Hash.

    Parameters:

    • request (::Google::Cloud::Kms::V1::GetCryptoKeyRequest, ::Hash)

      A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.

    • options (::Gapic::CallOptions, ::Hash) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries etc. Optional.

  • #get_crypto_key(name: nil) ⇒ ::Google::Cloud::Kms::V1::CryptoKey

    Pass arguments to get_crypto_key via keyword arguments. Note that at least one keyword argument is required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash as a request object (see above).

    Parameters:

    • name (::String) (defaults to: nil)

      Required. The name of the CryptoKey to get.

Yields:

  • (result, operation)

    Access the result along with the TransportOperation object

Yield Parameters:

Returns:

Raises:

  • (::Google::Cloud::Error)

    if the REST call is aborted.



874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
# File 'lib/google/cloud/kms/v1/key_management_service/rest/client.rb', line 874

def get_crypto_key request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Kms::V1::GetCryptoKeyRequest

  # Converts hash and nil to an options object
  options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h

  # Customize the options with defaults
   = @config.rpcs.get_crypto_key..to_h

  # Set x-goog-api-client and x-goog-user-project headers
  [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
    lib_name: @config.lib_name, lib_version: @config.lib_version,
    gapic_version: ::Google::Cloud::Kms::V1::VERSION,
    transports_version_send: [:rest]

  [:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  options.apply_defaults timeout:      @config.rpcs.get_crypto_key.timeout,
                         metadata:     ,
                         retry_policy: @config.rpcs.get_crypto_key.retry_policy

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.,
                         retry_policy: @config.retry_policy

  @key_management_service_stub.get_crypto_key request, options do |result, operation|
    yield result, operation if block_given?
    return result
  end
rescue ::Gapic::Rest::Error => e
  raise ::Google::Cloud::Error.from_error(e)
end

#get_crypto_key_version(request, options = nil) ⇒ ::Google::Cloud::Kms::V1::CryptoKeyVersion #get_crypto_key_version(name: nil) ⇒ ::Google::Cloud::Kms::V1::CryptoKeyVersion

Returns metadata for a given CryptoKeyVersion.

Examples:

Basic example

require "google/cloud/kms/v1"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Kms::V1::KeyManagementService::Rest::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Kms::V1::GetCryptoKeyVersionRequest.new

# Call the get_crypto_key_version method.
result = client.get_crypto_key_version request

# The returned object is of type Google::Cloud::Kms::V1::CryptoKeyVersion.
p result

Overloads:

  • #get_crypto_key_version(request, options = nil) ⇒ ::Google::Cloud::Kms::V1::CryptoKeyVersion

    Pass arguments to get_crypto_key_version via a request object, either of type GetCryptoKeyVersionRequest or an equivalent Hash.

    Parameters:

    • request (::Google::Cloud::Kms::V1::GetCryptoKeyVersionRequest, ::Hash)

      A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.

    • options (::Gapic::CallOptions, ::Hash) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries etc. Optional.

  • #get_crypto_key_version(name: nil) ⇒ ::Google::Cloud::Kms::V1::CryptoKeyVersion

    Pass arguments to get_crypto_key_version via keyword arguments. Note that at least one keyword argument is required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash as a request object (see above).

    Parameters:

Yields:

  • (result, operation)

    Access the result along with the TransportOperation object

Yield Parameters:

Returns:

Raises:

  • (::Google::Cloud::Error)

    if the REST call is aborted.



954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
# File 'lib/google/cloud/kms/v1/key_management_service/rest/client.rb', line 954

def get_crypto_key_version request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Kms::V1::GetCryptoKeyVersionRequest

  # Converts hash and nil to an options object
  options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h

  # Customize the options with defaults
   = @config.rpcs.get_crypto_key_version..to_h

  # Set x-goog-api-client and x-goog-user-project headers
  [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
    lib_name: @config.lib_name, lib_version: @config.lib_version,
    gapic_version: ::Google::Cloud::Kms::V1::VERSION,
    transports_version_send: [:rest]

  [:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  options.apply_defaults timeout:      @config.rpcs.get_crypto_key_version.timeout,
                         metadata:     ,
                         retry_policy: @config.rpcs.get_crypto_key_version.retry_policy

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.,
                         retry_policy: @config.retry_policy

  @key_management_service_stub.get_crypto_key_version request, options do |result, operation|
    yield result, operation if block_given?
    return result
  end
rescue ::Gapic::Rest::Error => e
  raise ::Google::Cloud::Error.from_error(e)
end

#get_import_job(request, options = nil) ⇒ ::Google::Cloud::Kms::V1::ImportJob #get_import_job(name: nil) ⇒ ::Google::Cloud::Kms::V1::ImportJob

Returns metadata for a given ImportJob.

Examples:

Basic example

require "google/cloud/kms/v1"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Kms::V1::KeyManagementService::Rest::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Kms::V1::GetImportJobRequest.new

# Call the get_import_job method.
result = client.get_import_job request

# The returned object is of type Google::Cloud::Kms::V1::ImportJob.
p result

Overloads:

  • #get_import_job(request, options = nil) ⇒ ::Google::Cloud::Kms::V1::ImportJob

    Pass arguments to get_import_job via a request object, either of type GetImportJobRequest or an equivalent Hash.

    Parameters:

    • request (::Google::Cloud::Kms::V1::GetImportJobRequest, ::Hash)

      A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.

    • options (::Gapic::CallOptions, ::Hash) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries etc. Optional.

  • #get_import_job(name: nil) ⇒ ::Google::Cloud::Kms::V1::ImportJob

    Pass arguments to get_import_job via keyword arguments. Note that at least one keyword argument is required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash as a request object (see above).

    Parameters:

    • name (::String) (defaults to: nil)

      Required. The name of the ImportJob to get.

Yields:

  • (result, operation)

    Access the result along with the TransportOperation object

Yield Parameters:

Returns:

Raises:

  • (::Google::Cloud::Error)

    if the REST call is aborted.



1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
# File 'lib/google/cloud/kms/v1/key_management_service/rest/client.rb', line 1117

def get_import_job request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Kms::V1::GetImportJobRequest

  # Converts hash and nil to an options object
  options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h

  # Customize the options with defaults
   = @config.rpcs.get_import_job..to_h

  # Set x-goog-api-client and x-goog-user-project headers
  [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
    lib_name: @config.lib_name, lib_version: @config.lib_version,
    gapic_version: ::Google::Cloud::Kms::V1::VERSION,
    transports_version_send: [:rest]

  [:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  options.apply_defaults timeout:      @config.rpcs.get_import_job.timeout,
                         metadata:     ,
                         retry_policy: @config.rpcs.get_import_job.retry_policy

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.,
                         retry_policy: @config.retry_policy

  @key_management_service_stub.get_import_job request, options do |result, operation|
    yield result, operation if block_given?
    return result
  end
rescue ::Gapic::Rest::Error => e
  raise ::Google::Cloud::Error.from_error(e)
end

#get_key_ring(request, options = nil) ⇒ ::Google::Cloud::Kms::V1::KeyRing #get_key_ring(name: nil) ⇒ ::Google::Cloud::Kms::V1::KeyRing

Returns metadata for a given KeyRing.

Examples:

Basic example

require "google/cloud/kms/v1"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Kms::V1::KeyManagementService::Rest::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Kms::V1::GetKeyRingRequest.new

# Call the get_key_ring method.
result = client.get_key_ring request

# The returned object is of type Google::Cloud::Kms::V1::KeyRing.
p result

Overloads:

  • #get_key_ring(request, options = nil) ⇒ ::Google::Cloud::Kms::V1::KeyRing

    Pass arguments to get_key_ring via a request object, either of type GetKeyRingRequest or an equivalent Hash.

    Parameters:

    • request (::Google::Cloud::Kms::V1::GetKeyRingRequest, ::Hash)

      A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.

    • options (::Gapic::CallOptions, ::Hash) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries etc. Optional.

  • #get_key_ring(name: nil) ⇒ ::Google::Cloud::Kms::V1::KeyRing

    Pass arguments to get_key_ring via keyword arguments. Note that at least one keyword argument is required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash as a request object (see above).

    Parameters:

    • name (::String) (defaults to: nil)

      Required. The name of the KeyRing to get.

Yields:

  • (result, operation)

    Access the result along with the TransportOperation object

Yield Parameters:

Returns:

Raises:

  • (::Google::Cloud::Error)

    if the REST call is aborted.



793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
# File 'lib/google/cloud/kms/v1/key_management_service/rest/client.rb', line 793

def get_key_ring request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Kms::V1::GetKeyRingRequest

  # Converts hash and nil to an options object
  options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h

  # Customize the options with defaults
   = @config.rpcs.get_key_ring..to_h

  # Set x-goog-api-client and x-goog-user-project headers
  [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
    lib_name: @config.lib_name, lib_version: @config.lib_version,
    gapic_version: ::Google::Cloud::Kms::V1::VERSION,
    transports_version_send: [:rest]

  [:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  options.apply_defaults timeout:      @config.rpcs.get_key_ring.timeout,
                         metadata:     ,
                         retry_policy: @config.rpcs.get_key_ring.retry_policy

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.,
                         retry_policy: @config.retry_policy

  @key_management_service_stub.get_key_ring request, options do |result, operation|
    yield result, operation if block_given?
    return result
  end
rescue ::Gapic::Rest::Error => e
  raise ::Google::Cloud::Error.from_error(e)
end

#get_public_key(request, options = nil) ⇒ ::Google::Cloud::Kms::V1::PublicKey #get_public_key(name: nil) ⇒ ::Google::Cloud::Kms::V1::PublicKey

Returns the public key for the given CryptoKeyVersion. The CryptoKey.purpose must be ASYMMETRIC_SIGN or ASYMMETRIC_DECRYPT.

Examples:

Basic example

require "google/cloud/kms/v1"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Kms::V1::KeyManagementService::Rest::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Kms::V1::GetPublicKeyRequest.new

# Call the get_public_key method.
result = client.get_public_key request

# The returned object is of type Google::Cloud::Kms::V1::PublicKey.
p result

Overloads:

  • #get_public_key(request, options = nil) ⇒ ::Google::Cloud::Kms::V1::PublicKey

    Pass arguments to get_public_key via a request object, either of type GetPublicKeyRequest or an equivalent Hash.

    Parameters:

    • request (::Google::Cloud::Kms::V1::GetPublicKeyRequest, ::Hash)

      A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.

    • options (::Gapic::CallOptions, ::Hash) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries etc. Optional.

  • #get_public_key(name: nil) ⇒ ::Google::Cloud::Kms::V1::PublicKey

    Pass arguments to get_public_key via keyword arguments. Note that at least one keyword argument is required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash as a request object (see above).

    Parameters:

    • name (::String) (defaults to: nil)

      Required. The name of the CryptoKeyVersion public key to get.

Yields:

  • (result, operation)

    Access the result along with the TransportOperation object

Yield Parameters:

Returns:

Raises:

  • (::Google::Cloud::Error)

    if the REST call is aborted.



1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
# File 'lib/google/cloud/kms/v1/key_management_service/rest/client.rb', line 1038

def get_public_key request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Kms::V1::GetPublicKeyRequest

  # Converts hash and nil to an options object
  options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h

  # Customize the options with defaults
   = @config.rpcs.get_public_key..to_h

  # Set x-goog-api-client and x-goog-user-project headers
  [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
    lib_name: @config.lib_name, lib_version: @config.lib_version,
    gapic_version: ::Google::Cloud::Kms::V1::VERSION,
    transports_version_send: [:rest]

  [:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  options.apply_defaults timeout:      @config.rpcs.get_public_key.timeout,
                         metadata:     ,
                         retry_policy: @config.rpcs.get_public_key.retry_policy

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.,
                         retry_policy: @config.retry_policy

  @key_management_service_stub.get_public_key request, options do |result, operation|
    yield result, operation if block_given?
    return result
  end
rescue ::Gapic::Rest::Error => e
  raise ::Google::Cloud::Error.from_error(e)
end

#import_crypto_key_version(request, options = nil) ⇒ ::Google::Cloud::Kms::V1::CryptoKeyVersion #import_crypto_key_version(parent: nil, crypto_key_version: nil, algorithm: nil, import_job: nil, wrapped_key: nil, rsa_aes_wrapped_key: nil) ⇒ ::Google::Cloud::Kms::V1::CryptoKeyVersion

Import wrapped key material into a CryptoKeyVersion.

All requests must specify a CryptoKey. If a CryptoKeyVersion is additionally specified in the request, key material will be reimported into that version. Otherwise, a new version will be created, and will be assigned the next sequential id within the CryptoKey.

Examples:

Basic example

require "google/cloud/kms/v1"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Kms::V1::KeyManagementService::Rest::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Kms::V1::ImportCryptoKeyVersionRequest.new

# Call the import_crypto_key_version method.
result = client.import_crypto_key_version request

# The returned object is of type Google::Cloud::Kms::V1::CryptoKeyVersion.
p result

Overloads:

  • #import_crypto_key_version(request, options = nil) ⇒ ::Google::Cloud::Kms::V1::CryptoKeyVersion

    Pass arguments to import_crypto_key_version via a request object, either of type ImportCryptoKeyVersionRequest or an equivalent Hash.

    Parameters:

    • request (::Google::Cloud::Kms::V1::ImportCryptoKeyVersionRequest, ::Hash)

      A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.

    • options (::Gapic::CallOptions, ::Hash) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries etc. Optional.

  • #import_crypto_key_version(parent: nil, crypto_key_version: nil, algorithm: nil, import_job: nil, wrapped_key: nil, rsa_aes_wrapped_key: nil) ⇒ ::Google::Cloud::Kms::V1::CryptoKeyVersion

    Pass arguments to import_crypto_key_version via keyword arguments. Note that at least one keyword argument is required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash as a request object (see above).

    Parameters:

    • parent (::String) (defaults to: nil)

      Required. The name of the CryptoKey to be imported into.

      The create permission is only required on this key when creating a new CryptoKeyVersion.

    • crypto_key_version (::String) (defaults to: nil)

      Optional. The optional name of an existing CryptoKeyVersion to target for an import operation. If this field is not present, a new CryptoKeyVersion containing the supplied key material is created.

      If this field is present, the supplied key material is imported into the existing CryptoKeyVersion. To import into an existing CryptoKeyVersion, the CryptoKeyVersion must be a child of ImportCryptoKeyVersionRequest.parent, have been previously created via [ImportCryptoKeyVersion][], and be in DESTROYED or IMPORT_FAILED state. The key material and algorithm must match the previous CryptoKeyVersion exactly if the CryptoKeyVersion has ever contained key material.

    • algorithm (::Google::Cloud::Kms::V1::CryptoKeyVersion::CryptoKeyVersionAlgorithm) (defaults to: nil)

      Required. The algorithm of the key being imported. This does not need to match the version_template of the CryptoKey this version imports into.

    • import_job (::String) (defaults to: nil)

      Required. The name of the ImportJob that was used to wrap this key material.

    • wrapped_key (::String) (defaults to: nil)

      Optional. The wrapped key material to import.

      Before wrapping, key material must be formatted. If importing symmetric key material, the expected key material format is plain bytes. If importing asymmetric key material, the expected key material format is PKCS#8-encoded DER (the PrivateKeyInfo structure from RFC 5208).

      When wrapping with import methods (RSA_OAEP_3072_SHA1_AES_256 or RSA_OAEP_4096_SHA1_AES_256 or RSA_OAEP_3072_SHA256_AES_256 or RSA_OAEP_4096_SHA256_AES_256),

      this field must contain the concatenation of:

      1. An ephemeral AES-256 wrapping key wrapped with the public_key using RSAES-OAEP with SHA-1/SHA-256, MGF1 with SHA-1/SHA-256, and an empty label.
      2. The formatted key to be imported, wrapped with the ephemeral AES-256 key using AES-KWP (RFC 5649).

      This format is the same as the format produced by PKCS#11 mechanism CKM_RSA_AES_KEY_WRAP.

      When wrapping with import methods (RSA_OAEP_3072_SHA256 or RSA_OAEP_4096_SHA256),

      this field must contain the formatted key to be imported, wrapped with the public_key using RSAES-OAEP with SHA-256, MGF1 with SHA-256, and an empty label.

    • rsa_aes_wrapped_key (::String) (defaults to: nil)

      Optional. This field has the same meaning as wrapped_key. Prefer to use that field in new work. Either that field or this field (but not both) must be specified.

Yields:

  • (result, operation)

    Access the result along with the TransportOperation object

Yield Parameters:

Returns:

Raises:

  • (::Google::Cloud::Error)

    if the REST call is aborted.



1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
# File 'lib/google/cloud/kms/v1/key_management_service/rest/client.rb', line 1556

def import_crypto_key_version request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Kms::V1::ImportCryptoKeyVersionRequest

  # Converts hash and nil to an options object
  options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h

  # Customize the options with defaults
   = @config.rpcs.import_crypto_key_version..to_h

  # Set x-goog-api-client and x-goog-user-project headers
  [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
    lib_name: @config.lib_name, lib_version: @config.lib_version,
    gapic_version: ::Google::Cloud::Kms::V1::VERSION,
    transports_version_send: [:rest]

  [:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  options.apply_defaults timeout:      @config.rpcs.import_crypto_key_version.timeout,
                         metadata:     ,
                         retry_policy: @config.rpcs.import_crypto_key_version.retry_policy

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.,
                         retry_policy: @config.retry_policy

  @key_management_service_stub.import_crypto_key_version request, options do |result, operation|
    yield result, operation if block_given?
    return result
  end
rescue ::Gapic::Rest::Error => e
  raise ::Google::Cloud::Error.from_error(e)
end

#list_crypto_key_versions(request, options = nil) ⇒ ::Gapic::Rest::PagedEnumerable<::Google::Cloud::Kms::V1::CryptoKeyVersion> #list_crypto_key_versions(parent: nil, page_size: nil, page_token: nil, view: nil, filter: nil, order_by: nil) ⇒ ::Gapic::Rest::PagedEnumerable<::Google::Cloud::Kms::V1::CryptoKeyVersion>

Examples:

Basic example

require "google/cloud/kms/v1"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Kms::V1::KeyManagementService::Rest::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Kms::V1::ListCryptoKeyVersionsRequest.new

# Call the list_crypto_key_versions method.
result = client.list_crypto_key_versions request

# The returned object is of type Gapic::PagedEnumerable. You can iterate
# over elements, and API calls will be issued to fetch pages as needed.
result.each do |item|
  # Each element is of type ::Google::Cloud::Kms::V1::CryptoKeyVersion.
  p item
end

Overloads:

  • #list_crypto_key_versions(request, options = nil) ⇒ ::Gapic::Rest::PagedEnumerable<::Google::Cloud::Kms::V1::CryptoKeyVersion>

    Pass arguments to list_crypto_key_versions via a request object, either of type ListCryptoKeyVersionsRequest or an equivalent Hash.

    Parameters:

    • request (::Google::Cloud::Kms::V1::ListCryptoKeyVersionsRequest, ::Hash)

      A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.

    • options (::Gapic::CallOptions, ::Hash) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries etc. Optional.

  • #list_crypto_key_versions(parent: nil, page_size: nil, page_token: nil, view: nil, filter: nil, order_by: nil) ⇒ ::Gapic::Rest::PagedEnumerable<::Google::Cloud::Kms::V1::CryptoKeyVersion>

    Pass arguments to list_crypto_key_versions via keyword arguments. Note that at least one keyword argument is required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash as a request object (see above).

    Parameters:

Yields:

  • (result, operation)

    Access the result along with the TransportOperation object

Yield Parameters:

Returns:

Raises:

  • (::Google::Cloud::Error)

    if the REST call is aborted.



608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
# File 'lib/google/cloud/kms/v1/key_management_service/rest/client.rb', line 608

def list_crypto_key_versions request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Kms::V1::ListCryptoKeyVersionsRequest

  # Converts hash and nil to an options object
  options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h

  # Customize the options with defaults
   = @config.rpcs.list_crypto_key_versions..to_h

  # Set x-goog-api-client and x-goog-user-project headers
  [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
    lib_name: @config.lib_name, lib_version: @config.lib_version,
    gapic_version: ::Google::Cloud::Kms::V1::VERSION,
    transports_version_send: [:rest]

  [:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  options.apply_defaults timeout:      @config.rpcs.list_crypto_key_versions.timeout,
                         metadata:     ,
                         retry_policy: @config.rpcs.list_crypto_key_versions.retry_policy

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.,
                         retry_policy: @config.retry_policy

  @key_management_service_stub.list_crypto_key_versions request, options do |result, operation|
    result = ::Gapic::Rest::PagedEnumerable.new @key_management_service_stub, :list_crypto_key_versions, "crypto_key_versions", request, result, options
    yield result, operation if block_given?
    return result
  end
rescue ::Gapic::Rest::Error => e
  raise ::Google::Cloud::Error.from_error(e)
end

#list_crypto_keys(request, options = nil) ⇒ ::Gapic::Rest::PagedEnumerable<::Google::Cloud::Kms::V1::CryptoKey> #list_crypto_keys(parent: nil, page_size: nil, page_token: nil, version_view: nil, filter: nil, order_by: nil) ⇒ ::Gapic::Rest::PagedEnumerable<::Google::Cloud::Kms::V1::CryptoKey>

Lists CryptoKeys.

Examples:

Basic example

require "google/cloud/kms/v1"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Kms::V1::KeyManagementService::Rest::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Kms::V1::ListCryptoKeysRequest.new

# Call the list_crypto_keys method.
result = client.list_crypto_keys request

# The returned object is of type Gapic::PagedEnumerable. You can iterate
# over elements, and API calls will be issued to fetch pages as needed.
result.each do |item|
  # Each element is of type ::Google::Cloud::Kms::V1::CryptoKey.
  p item
end

Overloads:

  • #list_crypto_keys(request, options = nil) ⇒ ::Gapic::Rest::PagedEnumerable<::Google::Cloud::Kms::V1::CryptoKey>

    Pass arguments to list_crypto_keys via a request object, either of type ListCryptoKeysRequest or an equivalent Hash.

    Parameters:

    • request (::Google::Cloud::Kms::V1::ListCryptoKeysRequest, ::Hash)

      A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.

    • options (::Gapic::CallOptions, ::Hash) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries etc. Optional.

  • #list_crypto_keys(parent: nil, page_size: nil, page_token: nil, version_view: nil, filter: nil, order_by: nil) ⇒ ::Gapic::Rest::PagedEnumerable<::Google::Cloud::Kms::V1::CryptoKey>

    Pass arguments to list_crypto_keys via keyword arguments. Note that at least one keyword argument is required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash as a request object (see above).

    Parameters:

Yields:

  • (result, operation)

    Access the result along with the TransportOperation object

Yield Parameters:

Returns:

Raises:

  • (::Google::Cloud::Error)

    if the REST call is aborted.



500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
# File 'lib/google/cloud/kms/v1/key_management_service/rest/client.rb', line 500

def list_crypto_keys request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Kms::V1::ListCryptoKeysRequest

  # Converts hash and nil to an options object
  options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h

  # Customize the options with defaults
   = @config.rpcs.list_crypto_keys..to_h

  # Set x-goog-api-client and x-goog-user-project headers
  [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
    lib_name: @config.lib_name, lib_version: @config.lib_version,
    gapic_version: ::Google::Cloud::Kms::V1::VERSION,
    transports_version_send: [:rest]

  [:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  options.apply_defaults timeout:      @config.rpcs.list_crypto_keys.timeout,
                         metadata:     ,
                         retry_policy: @config.rpcs.list_crypto_keys.retry_policy

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.,
                         retry_policy: @config.retry_policy

  @key_management_service_stub.list_crypto_keys request, options do |result, operation|
    result = ::Gapic::Rest::PagedEnumerable.new @key_management_service_stub, :list_crypto_keys, "crypto_keys", request, result, options
    yield result, operation if block_given?
    return result
  end
rescue ::Gapic::Rest::Error => e
  raise ::Google::Cloud::Error.from_error(e)
end

#list_import_jobs(request, options = nil) ⇒ ::Gapic::Rest::PagedEnumerable<::Google::Cloud::Kms::V1::ImportJob> #list_import_jobs(parent: nil, page_size: nil, page_token: nil, filter: nil, order_by: nil) ⇒ ::Gapic::Rest::PagedEnumerable<::Google::Cloud::Kms::V1::ImportJob>

Lists ImportJobs.

Examples:

Basic example

require "google/cloud/kms/v1"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Kms::V1::KeyManagementService::Rest::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Kms::V1::ListImportJobsRequest.new

# Call the list_import_jobs method.
result = client.list_import_jobs request

# The returned object is of type Gapic::PagedEnumerable. You can iterate
# over elements, and API calls will be issued to fetch pages as needed.
result.each do |item|
  # Each element is of type ::Google::Cloud::Kms::V1::ImportJob.
  p item
end

Overloads:

  • #list_import_jobs(request, options = nil) ⇒ ::Gapic::Rest::PagedEnumerable<::Google::Cloud::Kms::V1::ImportJob>

    Pass arguments to list_import_jobs via a request object, either of type ListImportJobsRequest or an equivalent Hash.

    Parameters:

    • request (::Google::Cloud::Kms::V1::ListImportJobsRequest, ::Hash)

      A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.

    • options (::Gapic::CallOptions, ::Hash) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries etc. Optional.

  • #list_import_jobs(parent: nil, page_size: nil, page_token: nil, filter: nil, order_by: nil) ⇒ ::Gapic::Rest::PagedEnumerable<::Google::Cloud::Kms::V1::ImportJob>

    Pass arguments to list_import_jobs via keyword arguments. Note that at least one keyword argument is required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash as a request object (see above).

    Parameters:

    • parent (::String) (defaults to: nil)

      Required. The resource name of the KeyRing to list, in the format projects/*/locations/*/keyRings/*.

    • page_size (::Integer) (defaults to: nil)

      Optional. Optional limit on the number of ImportJobs to include in the response. Further ImportJobs can subsequently be obtained by including the ListImportJobsResponse.next_page_token in a subsequent request. If unspecified, the server will pick an appropriate default.

    • page_token (::String) (defaults to: nil)

      Optional. Optional pagination token, returned earlier via ListImportJobsResponse.next_page_token.

    • filter (::String) (defaults to: nil)

      Optional. Only include resources that match the filter in the response. For more information, see Sorting and filtering list results.

    • order_by (::String) (defaults to: nil)

      Optional. Specify how the results should be sorted. If not specified, the results will be sorted in the default order. For more information, see Sorting and filtering list results.

Yields:

  • (result, operation)

    Access the result along with the TransportOperation object

Yield Parameters:

Returns:

Raises:

  • (::Google::Cloud::Error)

    if the REST call is aborted.



713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
# File 'lib/google/cloud/kms/v1/key_management_service/rest/client.rb', line 713

def list_import_jobs request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Kms::V1::ListImportJobsRequest

  # Converts hash and nil to an options object
  options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h

  # Customize the options with defaults
   = @config.rpcs.list_import_jobs..to_h

  # Set x-goog-api-client and x-goog-user-project headers
  [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
    lib_name: @config.lib_name, lib_version: @config.lib_version,
    gapic_version: ::Google::Cloud::Kms::V1::VERSION,
    transports_version_send: [:rest]

  [:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  options.apply_defaults timeout:      @config.rpcs.list_import_jobs.timeout,
                         metadata:     ,
                         retry_policy: @config.rpcs.list_import_jobs.retry_policy

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.,
                         retry_policy: @config.retry_policy

  @key_management_service_stub.list_import_jobs request, options do |result, operation|
    result = ::Gapic::Rest::PagedEnumerable.new @key_management_service_stub, :list_import_jobs, "import_jobs", request, result, options
    yield result, operation if block_given?
    return result
  end
rescue ::Gapic::Rest::Error => e
  raise ::Google::Cloud::Error.from_error(e)
end

#list_key_rings(request, options = nil) ⇒ ::Gapic::Rest::PagedEnumerable<::Google::Cloud::Kms::V1::KeyRing> #list_key_rings(parent: nil, page_size: nil, page_token: nil, filter: nil, order_by: nil) ⇒ ::Gapic::Rest::PagedEnumerable<::Google::Cloud::Kms::V1::KeyRing>

Lists KeyRings.

Examples:

Basic example

require "google/cloud/kms/v1"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Kms::V1::KeyManagementService::Rest::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Kms::V1::ListKeyRingsRequest.new

# Call the list_key_rings method.
result = client.list_key_rings request

# The returned object is of type Gapic::PagedEnumerable. You can iterate
# over elements, and API calls will be issued to fetch pages as needed.
result.each do |item|
  # Each element is of type ::Google::Cloud::Kms::V1::KeyRing.
  p item
end

Overloads:

  • #list_key_rings(request, options = nil) ⇒ ::Gapic::Rest::PagedEnumerable<::Google::Cloud::Kms::V1::KeyRing>

    Pass arguments to list_key_rings via a request object, either of type ListKeyRingsRequest or an equivalent Hash.

    Parameters:

    • request (::Google::Cloud::Kms::V1::ListKeyRingsRequest, ::Hash)

      A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.

    • options (::Gapic::CallOptions, ::Hash) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries etc. Optional.

  • #list_key_rings(parent: nil, page_size: nil, page_token: nil, filter: nil, order_by: nil) ⇒ ::Gapic::Rest::PagedEnumerable<::Google::Cloud::Kms::V1::KeyRing>

    Pass arguments to list_key_rings via keyword arguments. Note that at least one keyword argument is required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash as a request object (see above).

    Parameters:

    • parent (::String) (defaults to: nil)

      Required. The resource name of the location associated with the KeyRings, in the format projects/*/locations/*.

    • page_size (::Integer) (defaults to: nil)

      Optional. Optional limit on the number of KeyRings to include in the response. Further KeyRings can subsequently be obtained by including the ListKeyRingsResponse.next_page_token in a subsequent request. If unspecified, the server will pick an appropriate default.

    • page_token (::String) (defaults to: nil)

      Optional. Optional pagination token, returned earlier via ListKeyRingsResponse.next_page_token.

    • filter (::String) (defaults to: nil)

      Optional. Only include resources that match the filter in the response. For more information, see Sorting and filtering list results.

    • order_by (::String) (defaults to: nil)

      Optional. Specify how the results should be sorted. If not specified, the results will be sorted in the default order. For more information, see Sorting and filtering list results.

Yields:

  • (result, operation)

    Access the result along with the TransportOperation object

Yield Parameters:

Returns:

Raises:

  • (::Google::Cloud::Error)

    if the REST call is aborted.



393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
# File 'lib/google/cloud/kms/v1/key_management_service/rest/client.rb', line 393

def list_key_rings request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Kms::V1::ListKeyRingsRequest

  # Converts hash and nil to an options object
  options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h

  # Customize the options with defaults
   = @config.rpcs.list_key_rings..to_h

  # Set x-goog-api-client and x-goog-user-project headers
  [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
    lib_name: @config.lib_name, lib_version: @config.lib_version,
    gapic_version: ::Google::Cloud::Kms::V1::VERSION,
    transports_version_send: [:rest]

  [:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  options.apply_defaults timeout:      @config.rpcs.list_key_rings.timeout,
                         metadata:     ,
                         retry_policy: @config.rpcs.list_key_rings.retry_policy

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.,
                         retry_policy: @config.retry_policy

  @key_management_service_stub.list_key_rings request, options do |result, operation|
    result = ::Gapic::Rest::PagedEnumerable.new @key_management_service_stub, :list_key_rings, "key_rings", request, result, options
    yield result, operation if block_given?
    return result
  end
rescue ::Gapic::Rest::Error => e
  raise ::Google::Cloud::Error.from_error(e)
end

#mac_sign(request, options = nil) ⇒ ::Google::Cloud::Kms::V1::MacSignResponse #mac_sign(name: nil, data: nil, data_crc32c: nil) ⇒ ::Google::Cloud::Kms::V1::MacSignResponse

Signs data using a CryptoKeyVersion with CryptoKey.purpose MAC, producing a tag that can be verified by another source with the same key.

Examples:

Basic example

require "google/cloud/kms/v1"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Kms::V1::KeyManagementService::Rest::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Kms::V1::MacSignRequest.new

# Call the mac_sign method.
result = client.mac_sign request

# The returned object is of type Google::Cloud::Kms::V1::MacSignResponse.
p result

Overloads:

  • #mac_sign(request, options = nil) ⇒ ::Google::Cloud::Kms::V1::MacSignResponse

    Pass arguments to mac_sign via a request object, either of type MacSignRequest or an equivalent Hash.

    Parameters:

    • request (::Google::Cloud::Kms::V1::MacSignRequest, ::Hash)

      A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.

    • options (::Gapic::CallOptions, ::Hash) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries etc. Optional.

  • #mac_sign(name: nil, data: nil, data_crc32c: nil) ⇒ ::Google::Cloud::Kms::V1::MacSignResponse

    Pass arguments to mac_sign via keyword arguments. Note that at least one keyword argument is required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash as a request object (see above).

    Parameters:

    • name (::String) (defaults to: nil)

      Required. The resource name of the CryptoKeyVersion to use for signing.

    • data (::String) (defaults to: nil)

      Required. The data to sign. The MAC tag is computed over this data field based on the specific algorithm.

    • data_crc32c (::Google::Protobuf::Int64Value, ::Hash) (defaults to: nil)

      Optional. An optional CRC32C checksum of the MacSignRequest.data. If specified, KeyManagementService will verify the integrity of the received MacSignRequest.data using this checksum. KeyManagementService will report an error if the checksum verification fails. If you receive a checksum error, your client should verify that CRC32C(MacSignRequest.data) is equal to MacSignRequest.data_crc32c, and if so, perform a limited number of retries. A persistent mismatch may indicate an issue in your computation of the CRC32C checksum. Note: This field is defined as int64 for reasons of compatibility across different languages. However, it is a non-negative integer, which will never exceed 2^32-1, and can be safely downconverted to uint32 in languages that support this type.

Yields:

  • (result, operation)

    Access the result along with the TransportOperation object

Yield Parameters:

Returns:

Raises:

  • (::Google::Cloud::Error)

    if the REST call is aborted.



3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
# File 'lib/google/cloud/kms/v1/key_management_service/rest/client.rb', line 3033

def mac_sign request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Kms::V1::MacSignRequest

  # Converts hash and nil to an options object
  options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h

  # Customize the options with defaults
   = @config.rpcs.mac_sign..to_h

  # Set x-goog-api-client and x-goog-user-project headers
  [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
    lib_name: @config.lib_name, lib_version: @config.lib_version,
    gapic_version: ::Google::Cloud::Kms::V1::VERSION,
    transports_version_send: [:rest]

  [:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  options.apply_defaults timeout:      @config.rpcs.mac_sign.timeout,
                         metadata:     ,
                         retry_policy: @config.rpcs.mac_sign.retry_policy

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.,
                         retry_policy: @config.retry_policy

  @key_management_service_stub.mac_sign request, options do |result, operation|
    yield result, operation if block_given?
    return result
  end
rescue ::Gapic::Rest::Error => e
  raise ::Google::Cloud::Error.from_error(e)
end

#mac_verify(request, options = nil) ⇒ ::Google::Cloud::Kms::V1::MacVerifyResponse #mac_verify(name: nil, data: nil, data_crc32c: nil, mac: nil, mac_crc32c: nil) ⇒ ::Google::Cloud::Kms::V1::MacVerifyResponse

Verifies MAC tag using a CryptoKeyVersion with CryptoKey.purpose MAC, and returns a response that indicates whether or not the verification was successful.

Examples:

Basic example

require "google/cloud/kms/v1"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Kms::V1::KeyManagementService::Rest::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Kms::V1::MacVerifyRequest.new

# Call the mac_verify method.
result = client.mac_verify request

# The returned object is of type Google::Cloud::Kms::V1::MacVerifyResponse.
p result

Overloads:

  • #mac_verify(request, options = nil) ⇒ ::Google::Cloud::Kms::V1::MacVerifyResponse

    Pass arguments to mac_verify via a request object, either of type MacVerifyRequest or an equivalent Hash.

    Parameters:

    • request (::Google::Cloud::Kms::V1::MacVerifyRequest, ::Hash)

      A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.

    • options (::Gapic::CallOptions, ::Hash) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries etc. Optional.

  • #mac_verify(name: nil, data: nil, data_crc32c: nil, mac: nil, mac_crc32c: nil) ⇒ ::Google::Cloud::Kms::V1::MacVerifyResponse

    Pass arguments to mac_verify via keyword arguments. Note that at least one keyword argument is required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash as a request object (see above).

    Parameters:

    • name (::String) (defaults to: nil)

      Required. The resource name of the CryptoKeyVersion to use for verification.

    • data (::String) (defaults to: nil)

      Required. The data used previously as a MacSignRequest.data to generate the MAC tag.

    • data_crc32c (::Google::Protobuf::Int64Value, ::Hash) (defaults to: nil)

      Optional. An optional CRC32C checksum of the MacVerifyRequest.data. If specified, KeyManagementService will verify the integrity of the received MacVerifyRequest.data using this checksum. KeyManagementService will report an error if the checksum verification fails. If you receive a checksum error, your client should verify that CRC32C(MacVerifyRequest.data) is equal to MacVerifyRequest.data_crc32c, and if so, perform a limited number of retries. A persistent mismatch may indicate an issue in your computation of the CRC32C checksum. Note: This field is defined as int64 for reasons of compatibility across different languages. However, it is a non-negative integer, which will never exceed 2^32-1, and can be safely downconverted to uint32 in languages that support this type.

    • mac (::String) (defaults to: nil)

      Required. The signature to verify.

    • mac_crc32c (::Google::Protobuf::Int64Value, ::Hash) (defaults to: nil)

      Optional. An optional CRC32C checksum of the MacVerifyRequest.mac. If specified, KeyManagementService will verify the integrity of the received MacVerifyRequest.mac using this checksum. KeyManagementService will report an error if the checksum verification fails. If you receive a checksum error, your client should verify that CRC32C([MacVerifyRequest.tag][]) is equal to MacVerifyRequest.mac_crc32c, and if so, perform a limited number of retries. A persistent mismatch may indicate an issue in your computation of the CRC32C checksum. Note: This field is defined as int64 for reasons of compatibility across different languages. However, it is a non-negative integer, which will never exceed 2^32-1, and can be safely downconverted to uint32 in languages that support this type.

Yields:

  • (result, operation)

    Access the result along with the TransportOperation object

Yield Parameters:

Returns:

Raises:

  • (::Google::Cloud::Error)

    if the REST call is aborted.



3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
# File 'lib/google/cloud/kms/v1/key_management_service/rest/client.rb', line 3158

def mac_verify request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Kms::V1::MacVerifyRequest

  # Converts hash and nil to an options object
  options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h

  # Customize the options with defaults
   = @config.rpcs.mac_verify..to_h

  # Set x-goog-api-client and x-goog-user-project headers
  [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
    lib_name: @config.lib_name, lib_version: @config.lib_version,
    gapic_version: ::Google::Cloud::Kms::V1::VERSION,
    transports_version_send: [:rest]

  [:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  options.apply_defaults timeout:      @config.rpcs.mac_verify.timeout,
                         metadata:     ,
                         retry_policy: @config.rpcs.mac_verify.retry_policy

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.,
                         retry_policy: @config.retry_policy

  @key_management_service_stub.mac_verify request, options do |result, operation|
    yield result, operation if block_given?
    return result
  end
rescue ::Gapic::Rest::Error => e
  raise ::Google::Cloud::Error.from_error(e)
end

#raw_decrypt(request, options = nil) ⇒ ::Google::Cloud::Kms::V1::RawDecryptResponse #raw_decrypt(name: nil, ciphertext: nil, additional_authenticated_data: nil, initialization_vector: nil, tag_length: nil, ciphertext_crc32c: nil, additional_authenticated_data_crc32c: nil, initialization_vector_crc32c: nil) ⇒ ::Google::Cloud::Kms::V1::RawDecryptResponse

Decrypts data that was originally encrypted using a raw cryptographic mechanism. The CryptoKey.purpose must be RAW_ENCRYPT_DECRYPT.

Examples:

Basic example

require "google/cloud/kms/v1"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Kms::V1::KeyManagementService::Rest::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Kms::V1::RawDecryptRequest.new

# Call the raw_decrypt method.
result = client.raw_decrypt request

# The returned object is of type Google::Cloud::Kms::V1::RawDecryptResponse.
p result

Overloads:

  • #raw_decrypt(request, options = nil) ⇒ ::Google::Cloud::Kms::V1::RawDecryptResponse

    Pass arguments to raw_decrypt via a request object, either of type RawDecryptRequest or an equivalent Hash.

    Parameters:

    • request (::Google::Cloud::Kms::V1::RawDecryptRequest, ::Hash)

      A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.

    • options (::Gapic::CallOptions, ::Hash) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries etc. Optional.

  • #raw_decrypt(name: nil, ciphertext: nil, additional_authenticated_data: nil, initialization_vector: nil, tag_length: nil, ciphertext_crc32c: nil, additional_authenticated_data_crc32c: nil, initialization_vector_crc32c: nil) ⇒ ::Google::Cloud::Kms::V1::RawDecryptResponse

    Pass arguments to raw_decrypt via keyword arguments. Note that at least one keyword argument is required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash as a request object (see above).

    Parameters:

    • name (::String) (defaults to: nil)

      Required. The resource name of the CryptoKeyVersion to use for decryption.

    • ciphertext (::String) (defaults to: nil)

      Required. The encrypted data originally returned in RawEncryptResponse.ciphertext.

    • additional_authenticated_data (::String) (defaults to: nil)

      Optional. Optional data that must match the data originally supplied in RawEncryptRequest.additional_authenticated_data.

    • initialization_vector (::String) (defaults to: nil)

      Required. The initialization vector (IV) used during encryption, which must match the data originally provided in RawEncryptResponse.initialization_vector.

    • tag_length (::Integer) (defaults to: nil)

      The length of the authentication tag that is appended to the end of the ciphertext. If unspecified (0), the default value for the key's algorithm will be used (for AES-GCM, the default value is 16).

    • ciphertext_crc32c (::Google::Protobuf::Int64Value, ::Hash) (defaults to: nil)

      Optional. An optional CRC32C checksum of the RawDecryptRequest.ciphertext. If specified, KeyManagementService will verify the integrity of the received ciphertext using this checksum. KeyManagementService will report an error if the checksum verification fails. If you receive a checksum error, your client should verify that CRC32C(ciphertext) is equal to ciphertext_crc32c, and if so, perform a limited number of retries. A persistent mismatch may indicate an issue in your computation of the CRC32C checksum. Note: This field is defined as int64 for reasons of compatibility across different languages. However, it is a non-negative integer, which will never exceed 2^32-1, and can be safely downconverted to uint32 in languages that support this type.

    • additional_authenticated_data_crc32c (::Google::Protobuf::Int64Value, ::Hash) (defaults to: nil)

      Optional. An optional CRC32C checksum of the RawDecryptRequest.additional_authenticated_data. If specified, KeyManagementService will verify the integrity of the received additional_authenticated_data using this checksum. KeyManagementService will report an error if the checksum verification fails. If you receive a checksum error, your client should verify that CRC32C(additional_authenticated_data) is equal to additional_authenticated_data_crc32c, and if so, perform a limited number of retries. A persistent mismatch may indicate an issue in your computation of the CRC32C checksum. Note: This field is defined as int64 for reasons of compatibility across different languages. However, it is a non-negative integer, which will never exceed 2^32-1, and can be safely downconverted to uint32 in languages that support this type.

    • initialization_vector_crc32c (::Google::Protobuf::Int64Value, ::Hash) (defaults to: nil)

      Optional. An optional CRC32C checksum of the RawDecryptRequest.initialization_vector. If specified, KeyManagementService will verify the integrity of the received initialization_vector using this checksum. KeyManagementService will report an error if the checksum verification fails. If you receive a checksum error, your client should verify that CRC32C(initialization_vector) is equal to initialization_vector_crc32c, and if so, perform a limited number of retries. A persistent mismatch may indicate an issue in your computation of the CRC32C checksum. Note: This field is defined as int64 for reasons of compatibility across different languages. However, it is a non-negative integer, which will never exceed 2^32-1, and can be safely downconverted to uint32 in languages that support this type.

Yields:

  • (result, operation)

    Access the result along with the TransportOperation object

Yield Parameters:

Returns:

Raises:

  • (::Google::Cloud::Error)

    if the REST call is aborted.



2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
# File 'lib/google/cloud/kms/v1/key_management_service/rest/client.rb', line 2685

def raw_decrypt request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Kms::V1::RawDecryptRequest

  # Converts hash and nil to an options object
  options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h

  # Customize the options with defaults
   = @config.rpcs.raw_decrypt..to_h

  # Set x-goog-api-client and x-goog-user-project headers
  [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
    lib_name: @config.lib_name, lib_version: @config.lib_version,
    gapic_version: ::Google::Cloud::Kms::V1::VERSION,
    transports_version_send: [:rest]

  [:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  options.apply_defaults timeout:      @config.rpcs.raw_decrypt.timeout,
                         metadata:     ,
                         retry_policy: @config.rpcs.raw_decrypt.retry_policy

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.,
                         retry_policy: @config.retry_policy

  @key_management_service_stub.raw_decrypt request, options do |result, operation|
    yield result, operation if block_given?
    return result
  end
rescue ::Gapic::Rest::Error => e
  raise ::Google::Cloud::Error.from_error(e)
end

#raw_encrypt(request, options = nil) ⇒ ::Google::Cloud::Kms::V1::RawEncryptResponse #raw_encrypt(name: nil, plaintext: nil, additional_authenticated_data: nil, plaintext_crc32c: nil, additional_authenticated_data_crc32c: nil, initialization_vector: nil, initialization_vector_crc32c: nil) ⇒ ::Google::Cloud::Kms::V1::RawEncryptResponse

Encrypts data using portable cryptographic primitives. Most users should choose Encrypt and Decrypt rather than their raw counterparts. The CryptoKey.purpose must be RAW_ENCRYPT_DECRYPT.

Examples:

Basic example

require "google/cloud/kms/v1"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Kms::V1::KeyManagementService::Rest::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Kms::V1::RawEncryptRequest.new

# Call the raw_encrypt method.
result = client.raw_encrypt request

# The returned object is of type Google::Cloud::Kms::V1::RawEncryptResponse.
p result

Overloads:

  • #raw_encrypt(request, options = nil) ⇒ ::Google::Cloud::Kms::V1::RawEncryptResponse

    Pass arguments to raw_encrypt via a request object, either of type RawEncryptRequest or an equivalent Hash.

    Parameters:

    • request (::Google::Cloud::Kms::V1::RawEncryptRequest, ::Hash)

      A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.

    • options (::Gapic::CallOptions, ::Hash) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries etc. Optional.

  • #raw_encrypt(name: nil, plaintext: nil, additional_authenticated_data: nil, plaintext_crc32c: nil, additional_authenticated_data_crc32c: nil, initialization_vector: nil, initialization_vector_crc32c: nil) ⇒ ::Google::Cloud::Kms::V1::RawEncryptResponse

    Pass arguments to raw_encrypt via keyword arguments. Note that at least one keyword argument is required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash as a request object (see above).

    Parameters:

    • name (::String) (defaults to: nil)

      Required. The resource name of the CryptoKeyVersion to use for encryption.

    • plaintext (::String) (defaults to: nil)

      Required. The data to encrypt. Must be no larger than 64KiB.

      The maximum size depends on the key version's protection_level. For SOFTWARE keys, the plaintext must be no larger than 64KiB. For HSM keys, the combined length of the plaintext and additional_authenticated_data fields must be no larger than 8KiB.

    • additional_authenticated_data (::String) (defaults to: nil)

      Optional. Optional data that, if specified, must also be provided during decryption through RawDecryptRequest.additional_authenticated_data.

      This field may only be used in conjunction with an algorithm that accepts additional authenticated data (for example, AES-GCM).

      The maximum size depends on the key version's protection_level. For SOFTWARE keys, the plaintext must be no larger than 64KiB. For HSM keys, the combined length of the plaintext and additional_authenticated_data fields must be no larger than 8KiB.

    • plaintext_crc32c (::Google::Protobuf::Int64Value, ::Hash) (defaults to: nil)

      Optional. An optional CRC32C checksum of the RawEncryptRequest.plaintext. If specified, KeyManagementService will verify the integrity of the received plaintext using this checksum. KeyManagementService will report an error if the checksum verification fails. If you receive a checksum error, your client should verify that CRC32C(plaintext) is equal to plaintext_crc32c, and if so, perform a limited number of retries. A persistent mismatch may indicate an issue in your computation of the CRC32C checksum. Note: This field is defined as int64 for reasons of compatibility across different languages. However, it is a non-negative integer, which will never exceed 2^32-1, and can be safely downconverted to uint32 in languages that support this type.

    • additional_authenticated_data_crc32c (::Google::Protobuf::Int64Value, ::Hash) (defaults to: nil)

      Optional. An optional CRC32C checksum of the RawEncryptRequest.additional_authenticated_data. If specified, KeyManagementService will verify the integrity of the received additional_authenticated_data using this checksum. KeyManagementService will report an error if the checksum verification fails. If you receive a checksum error, your client should verify that CRC32C(additional_authenticated_data) is equal to additional_authenticated_data_crc32c, and if so, perform a limited number of retries. A persistent mismatch may indicate an issue in your computation of the CRC32C checksum. Note: This field is defined as int64 for reasons of compatibility across different languages. However, it is a non-negative integer, which will never exceed 2^32-1, and can be safely downconverted to uint32 in languages that support this type.

    • initialization_vector (::String) (defaults to: nil)

      Optional. A customer-supplied initialization vector that will be used for encryption. If it is not provided for AES-CBC and AES-CTR, one will be generated. It will be returned in RawEncryptResponse.initialization_vector.

    • initialization_vector_crc32c (::Google::Protobuf::Int64Value, ::Hash) (defaults to: nil)

      Optional. An optional CRC32C checksum of the RawEncryptRequest.initialization_vector. If specified, KeyManagementService will verify the integrity of the received initialization_vector using this checksum. KeyManagementService will report an error if the checksum verification fails. If you receive a checksum error, your client should verify that CRC32C(initialization_vector) is equal to initialization_vector_crc32c, and if so, perform a limited number of retries. A persistent mismatch may indicate an issue in your computation of the CRC32C checksum. Note: This field is defined as int64 for reasons of compatibility across different languages. However, it is a non-negative integer, which will never exceed 2^32-1, and can be safely downconverted to uint32 in languages that support this type.

Yields:

  • (result, operation)

    Access the result along with the TransportOperation object

Yield Parameters:

Returns:

Raises:

  • (::Google::Cloud::Error)

    if the REST call is aborted.



2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
# File 'lib/google/cloud/kms/v1/key_management_service/rest/client.rb', line 2539

def raw_encrypt request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Kms::V1::RawEncryptRequest

  # Converts hash and nil to an options object
  options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h

  # Customize the options with defaults
   = @config.rpcs.raw_encrypt..to_h

  # Set x-goog-api-client and x-goog-user-project headers
  [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
    lib_name: @config.lib_name, lib_version: @config.lib_version,
    gapic_version: ::Google::Cloud::Kms::V1::VERSION,
    transports_version_send: [:rest]

  [:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  options.apply_defaults timeout:      @config.rpcs.raw_encrypt.timeout,
                         metadata:     ,
                         retry_policy: @config.rpcs.raw_encrypt.retry_policy

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.,
                         retry_policy: @config.retry_policy

  @key_management_service_stub.raw_encrypt request, options do |result, operation|
    yield result, operation if block_given?
    return result
  end
rescue ::Gapic::Rest::Error => e
  raise ::Google::Cloud::Error.from_error(e)
end

#restore_crypto_key_version(request, options = nil) ⇒ ::Google::Cloud::Kms::V1::CryptoKeyVersion #restore_crypto_key_version(name: nil) ⇒ ::Google::Cloud::Kms::V1::CryptoKeyVersion

Restore a CryptoKeyVersion in the DESTROY_SCHEDULED state.

Upon restoration of the CryptoKeyVersion, state will be set to DISABLED, and destroy_time will be cleared.

Examples:

Basic example

require "google/cloud/kms/v1"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Kms::V1::KeyManagementService::Rest::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Kms::V1::RestoreCryptoKeyVersionRequest.new

# Call the restore_crypto_key_version method.
result = client.restore_crypto_key_version request

# The returned object is of type Google::Cloud::Kms::V1::CryptoKeyVersion.
p result

Overloads:

  • #restore_crypto_key_version(request, options = nil) ⇒ ::Google::Cloud::Kms::V1::CryptoKeyVersion

    Pass arguments to restore_crypto_key_version via a request object, either of type RestoreCryptoKeyVersionRequest or an equivalent Hash.

    Parameters:

    • request (::Google::Cloud::Kms::V1::RestoreCryptoKeyVersionRequest, ::Hash)

      A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.

    • options (::Gapic::CallOptions, ::Hash) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries etc. Optional.

  • #restore_crypto_key_version(name: nil) ⇒ ::Google::Cloud::Kms::V1::CryptoKeyVersion

    Pass arguments to restore_crypto_key_version via keyword arguments. Note that at least one keyword argument is required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash as a request object (see above).

    Parameters:

    • name (::String) (defaults to: nil)

      Required. The resource name of the CryptoKeyVersion to restore.

Yields:

  • (result, operation)

    Access the result along with the TransportOperation object

Yield Parameters:

Returns:

Raises:

  • (::Google::Cloud::Error)

    if the REST call is aborted.



2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
# File 'lib/google/cloud/kms/v1/key_management_service/rest/client.rb', line 2091

def restore_crypto_key_version request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Kms::V1::RestoreCryptoKeyVersionRequest

  # Converts hash and nil to an options object
  options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h

  # Customize the options with defaults
   = @config.rpcs.restore_crypto_key_version..to_h

  # Set x-goog-api-client and x-goog-user-project headers
  [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
    lib_name: @config.lib_name, lib_version: @config.lib_version,
    gapic_version: ::Google::Cloud::Kms::V1::VERSION,
    transports_version_send: [:rest]

  [:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  options.apply_defaults timeout:      @config.rpcs.restore_crypto_key_version.timeout,
                         metadata:     ,
                         retry_policy: @config.rpcs.restore_crypto_key_version.retry_policy

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.,
                         retry_policy: @config.retry_policy

  @key_management_service_stub.restore_crypto_key_version request, options do |result, operation|
    yield result, operation if block_given?
    return result
  end
rescue ::Gapic::Rest::Error => e
  raise ::Google::Cloud::Error.from_error(e)
end

#universe_domainString

The effective universe domain

Returns:

  • (String)


240
241
242
# File 'lib/google/cloud/kms/v1/key_management_service/rest/client.rb', line 240

def universe_domain
  @key_management_service_stub.universe_domain
end

#update_crypto_key(request, options = nil) ⇒ ::Google::Cloud::Kms::V1::CryptoKey #update_crypto_key(crypto_key: nil, update_mask: nil) ⇒ ::Google::Cloud::Kms::V1::CryptoKey

Update a CryptoKey.

Examples:

Basic example

require "google/cloud/kms/v1"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Kms::V1::KeyManagementService::Rest::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Kms::V1::UpdateCryptoKeyRequest.new

# Call the update_crypto_key method.
result = client.update_crypto_key request

# The returned object is of type Google::Cloud::Kms::V1::CryptoKey.
p result

Overloads:

  • #update_crypto_key(request, options = nil) ⇒ ::Google::Cloud::Kms::V1::CryptoKey

    Pass arguments to update_crypto_key via a request object, either of type UpdateCryptoKeyRequest or an equivalent Hash.

    Parameters:

    • request (::Google::Cloud::Kms::V1::UpdateCryptoKeyRequest, ::Hash)

      A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.

    • options (::Gapic::CallOptions, ::Hash) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries etc. Optional.

  • #update_crypto_key(crypto_key: nil, update_mask: nil) ⇒ ::Google::Cloud::Kms::V1::CryptoKey

    Pass arguments to update_crypto_key via keyword arguments. Note that at least one keyword argument is required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash as a request object (see above).

    Parameters:

Yields:

  • (result, operation)

    Access the result along with the TransportOperation object

Yield Parameters:

Returns:

Raises:

  • (::Google::Cloud::Error)

    if the REST call is aborted.



1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
# File 'lib/google/cloud/kms/v1/key_management_service/rest/client.rb', line 1726

def update_crypto_key request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Kms::V1::UpdateCryptoKeyRequest

  # Converts hash and nil to an options object
  options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h

  # Customize the options with defaults
   = @config.rpcs.update_crypto_key..to_h

  # Set x-goog-api-client and x-goog-user-project headers
  [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
    lib_name: @config.lib_name, lib_version: @config.lib_version,
    gapic_version: ::Google::Cloud::Kms::V1::VERSION,
    transports_version_send: [:rest]

  [:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  options.apply_defaults timeout:      @config.rpcs.update_crypto_key.timeout,
                         metadata:     ,
                         retry_policy: @config.rpcs.update_crypto_key.retry_policy

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.,
                         retry_policy: @config.retry_policy

  @key_management_service_stub.update_crypto_key request, options do |result, operation|
    yield result, operation if block_given?
    return result
  end
rescue ::Gapic::Rest::Error => e
  raise ::Google::Cloud::Error.from_error(e)
end

#update_crypto_key_primary_version(request, options = nil) ⇒ ::Google::Cloud::Kms::V1::CryptoKey #update_crypto_key_primary_version(name: nil, crypto_key_version_id: nil) ⇒ ::Google::Cloud::Kms::V1::CryptoKey

Update the version of a CryptoKey that will be used in Encrypt.

Returns an error if called on a key whose purpose is not ENCRYPT_DECRYPT.

Examples:

Basic example

require "google/cloud/kms/v1"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Kms::V1::KeyManagementService::Rest::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Kms::V1::UpdateCryptoKeyPrimaryVersionRequest.new

# Call the update_crypto_key_primary_version method.
result = client.update_crypto_key_primary_version request

# The returned object is of type Google::Cloud::Kms::V1::CryptoKey.
p result

Overloads:

  • #update_crypto_key_primary_version(request, options = nil) ⇒ ::Google::Cloud::Kms::V1::CryptoKey

    Pass arguments to update_crypto_key_primary_version via a request object, either of type UpdateCryptoKeyPrimaryVersionRequest or an equivalent Hash.

    Parameters:

    • request (::Google::Cloud::Kms::V1::UpdateCryptoKeyPrimaryVersionRequest, ::Hash)

      A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.

    • options (::Gapic::CallOptions, ::Hash) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries etc. Optional.

  • #update_crypto_key_primary_version(name: nil, crypto_key_version_id: nil) ⇒ ::Google::Cloud::Kms::V1::CryptoKey

    Pass arguments to update_crypto_key_primary_version via keyword arguments. Note that at least one keyword argument is required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash as a request object (see above).

    Parameters:

    • name (::String) (defaults to: nil)

      Required. The resource name of the CryptoKey to update.

    • crypto_key_version_id (::String) (defaults to: nil)

      Required. The id of the child CryptoKeyVersion to use as primary.

Yields:

  • (result, operation)

    Access the result along with the TransportOperation object

Yield Parameters:

Returns:

Raises:

  • (::Google::Cloud::Error)

    if the REST call is aborted.



1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
# File 'lib/google/cloud/kms/v1/key_management_service/rest/client.rb', line 1905

def update_crypto_key_primary_version request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Kms::V1::UpdateCryptoKeyPrimaryVersionRequest

  # Converts hash and nil to an options object
  options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h

  # Customize the options with defaults
   = @config.rpcs.update_crypto_key_primary_version..to_h

  # Set x-goog-api-client and x-goog-user-project headers
  [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
    lib_name: @config.lib_name, lib_version: @config.lib_version,
    gapic_version: ::Google::Cloud::Kms::V1::VERSION,
    transports_version_send: [:rest]

  [:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  options.apply_defaults timeout:      @config.rpcs.update_crypto_key_primary_version.timeout,
                         metadata:     ,
                         retry_policy: @config.rpcs.update_crypto_key_primary_version.retry_policy

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.,
                         retry_policy: @config.retry_policy

  @key_management_service_stub.update_crypto_key_primary_version request, options do |result, operation|
    yield result, operation if block_given?
    return result
  end
rescue ::Gapic::Rest::Error => e
  raise ::Google::Cloud::Error.from_error(e)
end

#update_crypto_key_version(request, options = nil) ⇒ ::Google::Cloud::Kms::V1::CryptoKeyVersion #update_crypto_key_version(crypto_key_version: nil, update_mask: nil) ⇒ ::Google::Cloud::Kms::V1::CryptoKeyVersion

Update a CryptoKeyVersion's metadata.

state may be changed between ENABLED and DISABLED using this method. See DestroyCryptoKeyVersion and RestoreCryptoKeyVersion to move between other states.

Examples:

Basic example

require "google/cloud/kms/v1"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Kms::V1::KeyManagementService::Rest::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Kms::V1::UpdateCryptoKeyVersionRequest.new

# Call the update_crypto_key_version method.
result = client.update_crypto_key_version request

# The returned object is of type Google::Cloud::Kms::V1::CryptoKeyVersion.
p result

Overloads:

Yields:

  • (result, operation)

    Access the result along with the TransportOperation object

Yield Parameters:

Returns:

Raises:

  • (::Google::Cloud::Error)

    if the REST call is aborted.



1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
# File 'lib/google/cloud/kms/v1/key_management_service/rest/client.rb', line 1818

def update_crypto_key_version request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Kms::V1::UpdateCryptoKeyVersionRequest

  # Converts hash and nil to an options object
  options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h

  # Customize the options with defaults
   = @config.rpcs.update_crypto_key_version..to_h

  # Set x-goog-api-client and x-goog-user-project headers
  [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
    lib_name: @config.lib_name, lib_version: @config.lib_version,
    gapic_version: ::Google::Cloud::Kms::V1::VERSION,
    transports_version_send: [:rest]

  [:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  options.apply_defaults timeout:      @config.rpcs.update_crypto_key_version.timeout,
                         metadata:     ,
                         retry_policy: @config.rpcs.update_crypto_key_version.retry_policy

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.,
                         retry_policy: @config.retry_policy

  @key_management_service_stub.update_crypto_key_version request, options do |result, operation|
    yield result, operation if block_given?
    return result
  end
rescue ::Gapic::Rest::Error => e
  raise ::Google::Cloud::Error.from_error(e)
end