lib/google/cloud/kms.rb in google-cloud-kms-2.7.0 vs lib/google/cloud/kms.rb in google-cloud-kms-2.8.1

- old
+ new

@@ -44,9 +44,99 @@ module Google module Cloud module Kms ## + # Create a new client object for Autokey. + # + # By default, this returns an instance of + # [Google::Cloud::Kms::V1::Autokey::Client](https://cloud.google.com/ruby/docs/reference/google-cloud-kms-v1/latest/Google-Cloud-Kms-V1-Autokey-Client) + # for a gRPC client for version V1 of the API. + # However, you can specify a different API version by passing it in the + # `version` parameter. If the Autokey service is + # supported by that API version, and the corresponding gem is available, the + # appropriate versioned client will be returned. + # You can also specify a different transport by passing `:rest` or `:grpc` in + # the `transport` parameter. + # + # ## About Autokey + # + # 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. + # + # @param version [::String, ::Symbol] The API version to connect to. Optional. + # Defaults to `:v1`. + # @param transport [:grpc, :rest] The transport to use. Defaults to `:grpc`. + # @return [::Object] A client object for the specified version. + # + def self.autokey version: :v1, transport: :grpc, &block + require "google/cloud/kms/#{version.to_s.downcase}" + + package_name = Google::Cloud::Kms + .constants + .select { |sym| sym.to_s.downcase == version.to_s.downcase.tr("_", "") } + .first + service_module = Google::Cloud::Kms.const_get(package_name).const_get(:Autokey) + service_module = service_module.const_get(:Rest) if transport == :rest + service_module.const_get(:Client).new(&block) + end + + ## + # Create a new client object for AutokeyAdmin. + # + # By default, this returns an instance of + # [Google::Cloud::Kms::V1::AutokeyAdmin::Client](https://cloud.google.com/ruby/docs/reference/google-cloud-kms-v1/latest/Google-Cloud-Kms-V1-AutokeyAdmin-Client) + # for a gRPC client for version V1 of the API. + # However, you can specify a different API version by passing it in the + # `version` parameter. If the AutokeyAdmin service is + # supported by that API version, and the corresponding gem is available, the + # appropriate versioned client will be returned. + # You can also specify a different transport by passing `:rest` or `:grpc` in + # the `transport` parameter. + # + # ## About AutokeyAdmin + # + # Provides interfaces for managing Cloud KMS Autokey folder-level + # configurations. A configuration is inherited by all descendent projects. A + # configuration at one folder overrides any other configurations in its + # ancestry. Setting a configuration on a folder is a prerequisite for Cloud KMS + # Autokey, so that users working in a descendant project can request + # provisioned CryptoKeys, ready for Customer + # Managed Encryption Key (CMEK) use, on-demand. + # + # @param version [::String, ::Symbol] The API version to connect to. Optional. + # Defaults to `:v1`. + # @param transport [:grpc, :rest] The transport to use. Defaults to `:grpc`. + # @return [::Object] A client object for the specified version. + # + def self.autokey_admin version: :v1, transport: :grpc, &block + require "google/cloud/kms/#{version.to_s.downcase}" + + package_name = Google::Cloud::Kms + .constants + .select { |sym| sym.to_s.downcase == version.to_s.downcase.tr("_", "") } + .first + service_module = Google::Cloud::Kms.const_get(package_name).const_get(:AutokeyAdmin) + service_module = service_module.const_get(:Rest) if transport == :rest + service_module.const_get(:Client).new(&block) + end + + ## # Create a new client object for EkmService. # # By default, this returns an instance of # [Google::Cloud::Kms::V1::EkmService::Client](https://cloud.google.com/ruby/docs/reference/google-cloud-kms-v1/latest/Google-Cloud-Kms-V1-EkmService-Client) # for a gRPC client for version V1 of the API.