class Google::Cloud::Bigquery::EncryptionConfiguration

# Encryption Configuration

A builder for BigQuery table encryption configurations, passed to block arguments to {Dataset#create_table} and {Table#encryption}.

@see cloud.google.com/bigquery/docs/customer-managed-encryption

Protecting Data with Cloud KMS Keys

@example

require "google/cloud/bigquery"

bigquery = Google::Cloud::Bigquery.new
dataset = bigquery.dataset "my_dataset"
key_name = "projects/a/locations/b/keyRings/c/cryptoKeys/d"
encrypt_config = bigquery.encryption kms_key: key_name
table = dataset.create_table "my_table" do |updater|
  updater.encryption = encrypt_config
end

Attributes

gapi[RW]

@private The Google API Client object.

Public Class Methods

from_gapi(gapi) click to toggle source

@private Google API Client object.

# File lib/google/cloud/bigquery/encryption_configuration.rb, line 102
def self.from_gapi gapi
  new_config = new
  new_config.instance_variable_set :@gapi, gapi
  new_config
end
new() click to toggle source

@private Create an empty EncryptionConfiguration object.

# File lib/google/cloud/bigquery/encryption_configuration.rb, line 47
def initialize
  @gapi = Google::Apis::BigqueryV2::EncryptionConfiguration.new
end

Public Instance Methods

==(other) click to toggle source

@private

# File lib/google/cloud/bigquery/encryption_configuration.rb, line 109
def == other
  return false unless other.is_a? EncryptionConfiguration
  to_gapi.to_json == other.to_gapi.to_json
end
changed?() click to toggle source

@private

# File lib/google/cloud/bigquery/encryption_configuration.rb, line 89
def changed?
  return false if frozen?
  @original_json != @gapi.to_json
end
kms_key() click to toggle source

The Cloud KMS encryption key that will be used to protect the table. For example: `projects/a/locations/b/keyRings/c/cryptoKeys/d` The default value is `nil`, which means default encryption is used.

@return [String]

@example

require "google/cloud/bigquery"

config = Google::Cloud::Bigquery::EncryptionConfiguration.new
key_name = "projects/a/locations/b/keyRings/c/cryptoKeys/d"
config.kms_key = key_name
# File lib/google/cloud/bigquery/encryption_configuration.rb, line 65
def kms_key
  @gapi.kms_key_name
end
kms_key=(new_kms_key_name) click to toggle source

Set the Cloud KMS encryption key that will be used to protect the table. For example: `projects/a/locations/b/keyRings/c/cryptoKeys/d` The default value is `nil`, which means default encryption is used.

@param [String] new_kms_key_name New Cloud KMS key name

@example

require "google/cloud/bigquery"

config = Google::Cloud::Bigquery::EncryptionConfiguration.new
key_name = "projects/a/locations/b/keyRings/c/cryptoKeys/d"
config.kms_key = key_name
# File lib/google/cloud/bigquery/encryption_configuration.rb, line 83
def kms_key= new_kms_key_name
  frozen_check!
  @gapi.kms_key_name = new_kms_key_name
end
to_gapi() click to toggle source

@private Google API Client object.

# File lib/google/cloud/bigquery/encryption_configuration.rb, line 96
def to_gapi
  @gapi
end

Protected Instance Methods

frozen_check!() click to toggle source
# File lib/google/cloud/bigquery/encryption_configuration.rb, line 116
def frozen_check!
  return unless frozen?
  raise ArgumentError, "Cannot modify a frozen encryption configuration"
end