Cloud Key Management Service (KMS) V1 API - Class Google::Cloud::Kms::V1::Autokey::Rest::Client (v0.27.0)

Reference documentation and code samples for the Cloud Key Management Service (KMS) V1 API class Google::Cloud::Kms::V1::Autokey::Rest::Client.

REST client for the Autokey service.

Provides interfaces for using Cloud KMS Autokey to provision new CryptoKeys, ready for Customer Managed Encryption Key (CMEK) use, on-demand. To support certain client tooling, this feature is modeled around a KeyHandle resource: creating a KeyHandle in a resource project and given location triggers Cloud KMS Autokey to provision a CryptoKey in the configured key project and the same location.

Prior to use in a given resource project, UpdateAutokeyConfig should have been called on an ancestor folder, setting the key project where Cloud KMS Autokey should create new CryptoKeys. See documentation for additional prerequisites. To check what key project, if any, is currently configured on a resource project's ancestor folder, see ShowEffectiveAutokeyConfig.

Inherits

  • Object

Methods

.configure

def self.configure() { |config| ... } -> Client::Configuration

Configure the Autokey Client class.

See Configuration for a description of the configuration fields.

Yields
  • (config) — Configure the Client client.
Yield Parameter
Example
# Modify the configuration for all Autokey clients
::Google::Cloud::Kms::V1::Autokey::Rest::Client.configure do |config|
  config.timeout = 10.0
end

#configure

def configure() { |config| ... } -> Client::Configuration

Configure the Autokey 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 Client.configure.

See Configuration for a description of the configuration fields.

Yields
  • (config) — Configure the Client client.
Yield Parameter

#create_key_handle

def create_key_handle(request, options = nil) -> ::Gapic::Operation
def create_key_handle(parent: nil, key_handle_id: nil, key_handle: nil) -> ::Gapic::Operation

Creates a new KeyHandle, triggering the provisioning of a new CryptoKey for CMEK use with the given resource type in the configured key project and the same location. [GetOperation][Operations.GetOperation] should be used to resolve the resulting long-running operation and get the resulting KeyHandle and CryptoKey.

Overloads
def create_key_handle(request, options = nil) -> ::Gapic::Operation
Pass arguments to create_key_handle via a request object, either of type CreateKeyHandleRequest or an equivalent Hash.
Parameters
  • request (::Google::Cloud::Kms::V1::CreateKeyHandleRequest, ::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) — Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
def create_key_handle(parent: nil, key_handle_id: nil, key_handle: nil) -> ::Gapic::Operation
Pass arguments to create_key_handle 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) — Required. Name of the resource project and location to create the KeyHandle in, e.g. projects/{PROJECT_ID}/locations/{LOCATION}.
  • key_handle_id (::String) — Optional. Id of the KeyHandle. Must be unique to the resource project and location. If not provided by the caller, a new UUID is used.
  • key_handle (::Google::Cloud::Kms::V1::KeyHandle, ::Hash) — Required. KeyHandle to create.
Yields
  • (result, operation) — Access the result along with the TransportOperation object
Yield Parameters
  • result (::Gapic::Operation)
  • operation (::Gapic::Rest::TransportOperation)
Returns
  • (::Gapic::Operation)
Raises
  • (::Google::Cloud::Error) — if the REST call is aborted.
Example

Basic example

require "google/cloud/kms/v1"

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

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

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

# The returned object is of type Gapic::Operation. You can use it to
# check the status of an operation, cancel it, or wait for results.
# Here is how to wait for a response.
result.wait_until_done! timeout: 60
if result.response?
  p result.response
else
  puts "No response received."
end

#get_key_handle

def get_key_handle(request, options = nil) -> ::Google::Cloud::Kms::V1::KeyHandle
def get_key_handle(name: nil) -> ::Google::Cloud::Kms::V1::KeyHandle

Returns the KeyHandle.

Overloads
def get_key_handle(request, options = nil) -> ::Google::Cloud::Kms::V1::KeyHandle
Pass arguments to get_key_handle via a request object, either of type GetKeyHandleRequest or an equivalent Hash.
Parameters
  • request (::Google::Cloud::Kms::V1::GetKeyHandleRequest, ::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) — Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
def get_key_handle(name: nil) -> ::Google::Cloud::Kms::V1::KeyHandle
Pass arguments to get_key_handle 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).
Parameter
  • name (::String) — Required. Name of the KeyHandle resource, e.g. projects/{PROJECT_ID}/locations/{LOCATION}/keyHandles/{KEY_HANDLE_ID}.
Yields
  • (result, operation) — Access the result along with the TransportOperation object
Yield Parameters
Raises
  • (::Google::Cloud::Error) — if the REST call is aborted.
Example

Basic example

require "google/cloud/kms/v1"

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

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

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

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

#iam_policy_client

def iam_policy_client() -> Google::Iam::V1::IAMPolicy::Rest::Client

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

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

#initialize

def initialize() { |config| ... } -> Client

Create a new Autokey REST client object.

Yields
  • (config) — Configure the Autokey client.
Yield Parameter
Returns
  • (Client) — a new instance of Client
Example
# Create a client using the default configuration
client = ::Google::Cloud::Kms::V1::Autokey::Rest::Client.new

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

#list_key_handles

def list_key_handles(request, options = nil) -> ::Google::Cloud::Kms::V1::ListKeyHandlesResponse
def list_key_handles(parent: nil, filter: nil) -> ::Google::Cloud::Kms::V1::ListKeyHandlesResponse

Lists KeyHandles.

Overloads
def list_key_handles(request, options = nil) -> ::Google::Cloud::Kms::V1::ListKeyHandlesResponse
Pass arguments to list_key_handles via a request object, either of type ListKeyHandlesRequest or an equivalent Hash.
Parameters
  • request (::Google::Cloud::Kms::V1::ListKeyHandlesRequest, ::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) — Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
def list_key_handles(parent: nil, filter: nil) -> ::Google::Cloud::Kms::V1::ListKeyHandlesResponse
Pass arguments to list_key_handles 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) — Required. Name of the resource project and location from which to list KeyHandles, e.g. projects/{PROJECT_ID}/locations/{LOCATION}.
  • filter (::String) — Optional. Filter to apply when listing KeyHandles, e.g. resource_type_selector="{SERVICE}.googleapis.com/{TYPE}".
Yields
  • (result, operation) — Access the result along with the TransportOperation object
Yield Parameters
Raises
  • (::Google::Cloud::Error) — if the REST call is aborted.
Example

Basic example

require "google/cloud/kms/v1"

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

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

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

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

#location_client

def location_client() -> Google::Cloud::Location::Locations::Rest::Client

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

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

#operations_client

def operations_client() -> ::Google::Cloud::Kms::V1::Autokey::Rest::Operations

Get the associated client for long-running operations.

#universe_domain

def universe_domain() -> String

The effective universe domain

Returns
  • (String)