Module: Google::Cloud::Spanner::Admin::Instance
- Defined in:
- lib/google/cloud/spanner/admin/instance.rb,
lib/google/cloud/spanner/admin/instance/credentials.rb
Defined Under Namespace
Classes: Configuration
Constant Summary collapse
- Credentials =
Deprecated.
Use version-specific credentials classes
V1::InstanceAdmin::Credentials
Class Method Summary collapse
-
.configure {|@configure| ... } ⇒ ::Google::Cloud::Config
Configure the Google Cloud Spanner Instance Admin library.
-
.instance_admin(project_id: nil, credentials: nil, scope: nil, timeout: nil, endpoint: nil, project: nil, keyfile: nil, emulator_host: nil, lib_name: nil, lib_version: nil) ⇒ Admin::Instance::V1::InstanceAdmin::Client
Create a new client object for a InstanceAdmin.
Class Method Details
.configure {|@configure| ... } ⇒ ::Google::Cloud::Config
Configure the Google Cloud Spanner Instance Admin library. This configuration can be applied globally to all clients.
The following configuration parameters are supported:
credentials
(type:String, Hash, Google::Auth::Credentials
) - The path to the keyfile as a String, the contents of the keyfile as a Hash, or a Google::Auth::Credentials object.lib_name
(type:String
) - The library name as recorded in instrumentation and logging.lib_version
(type:String
) - The library version as recorded in instrumentation and logging.interceptors
(type:Array<GRPC::ClientInterceptor>
) - An array of interceptors that are run before calls are executed.timeout
(type:Numeric
) - Default timeout in seconds.emulator_host
- (String) Host name of the emulator. Defaults toENV["SPANNER_EMULATOR_HOST"]
.metadata
(type:Hash{Symbol=>String}
) - Additional gRPC headers to be sent with the call.retry_policy
(type:Hash
) - The retry policy. The value is a hash with the following keys::initial_delay
(type:Numeric
) - The initial delay in seconds.:max_delay
(type:Numeric
) - The max delay in seconds.:multiplier
(type:Numeric
) - The incremental backoff multiplier.:retry_codes
(type:Array<String>
) - The error codes that should trigger a retry.
173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 |
# File 'lib/google/cloud/spanner/admin/instance.rb', line 173 def self.configure @configure ||= begin namespace = ["Google", "Cloud", "Spanner"] 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 = Instance::Configuration.new parent_config default_config end yield @configure if block_given? @configure end |
.instance_admin(project_id: nil, credentials: nil, scope: nil, timeout: nil, endpoint: nil, project: nil, keyfile: nil, emulator_host: nil, lib_name: nil, lib_version: nil) ⇒ Admin::Instance::V1::InstanceAdmin::Client
Create a new client object for a InstanceAdmin.
This returns an instance of Google::Cloud::Spanner::Admin::Instance::V1::InstanceAdmin::Client for version V1 of the API.
About InstanceAdmin
Google Cloud Spanner Instance Admin Service
The Cloud Spanner Instance Admin API can be used to create, delete, modify and list instances. Instances are dedicated Cloud Spanner serving and storage resources to be used by Cloud Spanner databases.
For more information on connecting to Google Cloud see the Authentication Guide.
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 |
# File 'lib/google/cloud/spanner/admin/instance.rb', line 86 def self.instance_admin project_id: nil, credentials: nil, scope: nil, timeout: nil, endpoint: nil, project: nil, keyfile: nil, emulator_host: nil, lib_name: nil, lib_version: nil project_id ||= project || default_project_id scope ||= configure.scope timeout ||= configure.timeout emulator_host ||= configure.emulator_host endpoint ||= emulator_host || configure.endpoint credentials ||= keyfile lib_name ||= configure.lib_name lib_version ||= configure.lib_version if emulator_host credentials = :this_channel_is_insecure else credentials ||= default_credentials scope: scope unless credentials.is_a? Google::Auth::Credentials credentials = Spanner::Credentials.new credentials, scope: scope end if credentials.respond_to? :project_id project_id ||= credentials.project_id end end project_id = project_id.to_s # Always cast to a string raise ArgumentError, "project_id is missing" if project_id.empty? configure.quota_project ||= credentials.quota_project_id if credentials.respond_to? :quota_project_id Admin::Instance::V1::InstanceAdmin::Client.new do |config| config.credentials = channel endpoint, credentials config.quota_project = configure.quota_project config.timeout = timeout if timeout config.endpoint = endpoint if endpoint config.lib_name = lib_name_with_prefix lib_name, lib_version config.lib_version = Google::Cloud::Spanner::VERSION config. = { "google-cloud-resource-prefix" => "projects/#{project_id}" } end end |