class Google::Cloud::Spanner::V1::Spanner::Client
transactions on data stored in Cloud Spanner databases.
The Cloud Spanner API can be used to manage sessions and execute
Cloud Spanner API
Client for the Spanner service.
#
def self.configure
-
(Client::Configuration)
-
Other tags:
- Yieldparam: config -
Other tags:
- Yield: - Configure the Client client.
def self.configure @configure ||= begin namespace = ["Google", "Cloud", "Spanner", "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.create_session.timeout = 30.0 default_config.rpcs.create_session.retry_policy = { initial_delay: 0.25, max_delay: 32.0, multiplier: 1.3, retry_codes: [14, 8] } default_config.rpcs.batch_create_sessions.timeout = 60.0 default_config.rpcs.batch_create_sessions.retry_policy = { initial_delay: 0.25, max_delay: 32.0, multiplier: 1.3, retry_codes: [14, 8] } default_config.rpcs.get_session.timeout = 30.0 default_config.rpcs.get_session.retry_policy = { initial_delay: 0.25, max_delay: 32.0, multiplier: 1.3, retry_codes: [14, 8] } default_config.rpcs.list_sessions.timeout = 3600.0 default_config.rpcs.list_sessions.retry_policy = { initial_delay: 0.25, max_delay: 32.0, multiplier: 1.3, retry_codes: [14, 8] } default_config.rpcs.delete_session.timeout = 30.0 default_config.rpcs.delete_session.retry_policy = { initial_delay: 0.25, max_delay: 32.0, multiplier: 1.3, retry_codes: [14, 8] } default_config.rpcs.execute_sql.timeout = 30.0 default_config.rpcs.execute_sql.retry_policy = { initial_delay: 0.25, max_delay: 32.0, multiplier: 1.3, retry_codes: [14, 8] } default_config.rpcs.execute_streaming_sql.timeout = 3600.0 default_config.rpcs.execute_batch_dml.timeout = 30.0 default_config.rpcs.execute_batch_dml.retry_policy = { initial_delay: 0.25, max_delay: 32.0, multiplier: 1.3, retry_codes: [14, 8] } default_config.rpcs.read.timeout = 30.0 default_config.rpcs.read.retry_policy = { initial_delay: 0.25, max_delay: 32.0, multiplier: 1.3, retry_codes: [14, 8] } default_config.rpcs.streaming_read.timeout = 3600.0 default_config.rpcs.begin_transaction.timeout = 30.0 default_config.rpcs.begin_transaction.retry_policy = { initial_delay: 0.25, max_delay: 32.0, multiplier: 1.3, retry_codes: [14, 8] } default_config.rpcs.commit.timeout = 3600.0 default_config.rpcs.commit.retry_policy = { initial_delay: 0.25, max_delay: 32.0, multiplier: 1.3, retry_codes: [14, 8] } default_config.rpcs.rollback.timeout = 30.0 default_config.rpcs.rollback.retry_policy = { initial_delay: 0.25, max_delay: 32.0, multiplier: 1.3, retry_codes: [14, 8] } default_config.rpcs.partition_query.timeout = 30.0 default_config.rpcs.partition_query.retry_policy = { initial_delay: 0.25, max_delay: 32.0, multiplier: 1.3, retry_codes: [14, 8] } default_config.rpcs.partition_read.timeout = 30.0 default_config.rpcs.partition_read.retry_policy = { initial_delay: 0.25, max_delay: 32.0, multiplier: 1.3, retry_codes: [14, 8] } default_config.rpcs.batch_write.timeout = 3600.0 default_config end yield @configure if block_given? @configure end
def batch_create_sessions request, options = nil
- Example: Basic example -
Raises:
-
(::Google::Cloud::Error)
- if the RPC is aborted.
Returns:
-
(::Google::Cloud::Spanner::V1::BatchCreateSessionsResponse)
-
Other tags:
- Yieldparam: operation -
Yieldparam: response -
Other tags:
- Yield: - Access the result along with the RPC operation
Parameters:
-
session_count
(::Integer
) -- -
session_template
(::Google::Cloud::Spanner::V1::Session, ::Hash
) -- -
database
(::String
) -- -
options
(::Gapic::CallOptions, ::Hash
) -- -
request
(::Google::Cloud::Spanner::V1::BatchCreateSessionsRequest, ::Hash
) --
Overloads:
-
batch_create_sessions(database: nil, session_template: nil, session_count: nil)
-
batch_create_sessions(request, options = nil)
def batch_create_sessions request, options = nil raise ::ArgumentError, "request must be provided" if request.nil? request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Spanner::V1::BatchCreateSessionsRequest # 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 metadata = @config.rpcs.batch_create_sessions.metadata.to_h # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \ lib_name: @config.lib_name, lib_version: @config.lib_version, gapic_version: ::Google::Cloud::Spanner::V1::VERSION metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty? metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id header_params = {} if request.database header_params["database"] = request.database end request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&") metadata[:"x-goog-request-params"] ||= request_params_header options.apply_defaults timeout: @config.rpcs.batch_create_sessions.timeout, metadata: metadata, retry_policy: @config.rpcs.batch_create_sessions.retry_policy options.apply_defaults timeout: @config.timeout, metadata: @config.metadata, retry_policy: @config.retry_policy @spanner_stub.call_rpc :batch_create_sessions, request, options: options do |response, operation| yield response, operation if block_given? end rescue ::GRPC::BadStatus => e raise ::Google::Cloud::Error.from_error(e) end
def batch_write request, options = nil
- Example: Basic example -
Raises:
-
(::Google::Cloud::Error)
- if the RPC is aborted.
Returns:
-
(::Enumerable<::Google::Cloud::Spanner::V1::BatchWriteResponse>)
-
Other tags:
- Yieldparam: operation -
Yieldparam: response -
Other tags:
- Yield: - Access the result along with the RPC operation
Parameters:
-
exclude_txn_from_change_streams
(::Boolean
) -- -
mutation_groups
(::Array<::Google::Cloud::Spanner::V1::BatchWriteRequest::MutationGroup, ::Hash>
) -- -
request_options
(::Google::Cloud::Spanner::V1::RequestOptions, ::Hash
) -- -
session
(::String
) -- -
options
(::Gapic::CallOptions, ::Hash
) -- -
request
(::Google::Cloud::Spanner::V1::BatchWriteRequest, ::Hash
) --
Overloads:
-
batch_write(session: nil, request_options: nil, mutation_groups: nil, exclude_txn_from_change_streams: nil)
-
batch_write(request, options = nil)
def batch_write request, options = nil raise ::ArgumentError, "request must be provided" if request.nil? request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Spanner::V1::BatchWriteRequest # 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 metadata = @config.rpcs.batch_write.metadata.to_h # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \ lib_name: @config.lib_name, lib_version: @config.lib_version, gapic_version: ::Google::Cloud::Spanner::V1::VERSION metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty? metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id header_params = {} if request.session header_params["session"] = request.session end request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&") metadata[:"x-goog-request-params"] ||= request_params_header options.apply_defaults timeout: @config.rpcs.batch_write.timeout, metadata: metadata, retry_policy: @config.rpcs.batch_write.retry_policy options.apply_defaults timeout: @config.timeout, metadata: @config.metadata, retry_policy: @config.retry_policy @spanner_stub.call_rpc :batch_write, request, options: options do |response, operation| yield response, operation if block_given? end rescue ::GRPC::BadStatus => e raise ::Google::Cloud::Error.from_error(e) end
def begin_transaction request, options = nil
- Example: Basic example -
Raises:
-
(::Google::Cloud::Error)
- if the RPC is aborted.
Returns:
-
(::Google::Cloud::Spanner::V1::Transaction)
-
Other tags:
- Yieldparam: operation -
Yieldparam: response -
Other tags:
- Yield: - Access the result along with the RPC operation
Parameters:
-
mutation_key
(::Google::Cloud::Spanner::V1::Mutation, ::Hash
) -- -
request_options
(::Google::Cloud::Spanner::V1::RequestOptions, ::Hash
) -- -
options
(::Google::Cloud::Spanner::V1::TransactionOptions, ::Hash
) -- -
session
(::String
) -- -
options
(::Gapic::CallOptions, ::Hash
) -- -
request
(::Google::Cloud::Spanner::V1::BeginTransactionRequest, ::Hash
) --
Overloads:
-
begin_transaction(session: nil, options: nil, request_options: nil, mutation_key: nil)
-
begin_transaction(request, options = nil)
def begin_transaction request, options = nil raise ::ArgumentError, "request must be provided" if request.nil? request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Spanner::V1::BeginTransactionRequest # 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 metadata = @config.rpcs.begin_transaction.metadata.to_h # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \ lib_name: @config.lib_name, lib_version: @config.lib_version, gapic_version: ::Google::Cloud::Spanner::V1::VERSION metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty? metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id header_params = {} if request.session header_params["session"] = request.session end request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&") metadata[:"x-goog-request-params"] ||= request_params_header options.apply_defaults timeout: @config.rpcs.begin_transaction.timeout, metadata: metadata, retry_policy: @config.rpcs.begin_transaction.retry_policy options.apply_defaults timeout: @config.timeout, metadata: @config.metadata, retry_policy: @config.retry_policy @spanner_stub.call_rpc :begin_transaction, request, options: options do |response, operation| yield response, operation if block_given? end rescue ::GRPC::BadStatus => e raise ::Google::Cloud::Error.from_error(e) end
def commit request, options = nil
- Example: Basic example -
Raises:
-
(::Google::Cloud::Error)
- if the RPC is aborted.
Returns:
-
(::Google::Cloud::Spanner::V1::CommitResponse)
-
Other tags:
- Yieldparam: operation -
Yieldparam: response -
Other tags:
- Yield: - Access the result along with the RPC operation
Parameters:
-
precommit_token
(::Google::Cloud::Spanner::V1::MultiplexedSessionPrecommitToken, ::Hash
) -- -
request_options
(::Google::Cloud::Spanner::V1::RequestOptions, ::Hash
) -- -
max_commit_delay
(::Google::Protobuf::Duration, ::Hash
) -- -
return_commit_stats
(::Boolean
) -- -
mutations
(::Array<::Google::Cloud::Spanner::V1::Mutation, ::Hash>
) -- -
single_use_transaction
(::Google::Cloud::Spanner::V1::TransactionOptions, ::Hash
) -- -
transaction_id
(::String
) -- -
session
(::String
) -- -
options
(::Gapic::CallOptions, ::Hash
) -- -
request
(::Google::Cloud::Spanner::V1::CommitRequest, ::Hash
) --
Overloads:
-
commit(session: nil, transaction_id: nil, single_use_transaction: nil, mutations: nil, return_commit_stats: nil, max_commit_delay: nil, request_options: nil, precommit_token: nil)
-
commit(request, options = nil)
def commit request, options = nil raise ::ArgumentError, "request must be provided" if request.nil? request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Spanner::V1::CommitRequest # 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 metadata = @config.rpcs.commit.metadata.to_h # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \ lib_name: @config.lib_name, lib_version: @config.lib_version, gapic_version: ::Google::Cloud::Spanner::V1::VERSION metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty? metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id header_params = {} if request.session header_params["session"] = request.session end request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&") metadata[:"x-goog-request-params"] ||= request_params_header options.apply_defaults timeout: @config.rpcs.commit.timeout, metadata: metadata, retry_policy: @config.rpcs.commit.retry_policy options.apply_defaults timeout: @config.timeout, metadata: @config.metadata, retry_policy: @config.retry_policy @spanner_stub.call_rpc :commit, request, options: options do |response, operation| yield response, operation if block_given? end rescue ::GRPC::BadStatus => e raise ::Google::Cloud::Error.from_error(e) end
def configure
-
(Client::Configuration)
-
Other tags:
- Yieldparam: config -
Other tags:
- Yield: - Configure the Client client.
def configure yield @config if block_given? @config end
def create_session request, options = nil
- Example: Basic example -
Raises:
-
(::Google::Cloud::Error)
- if the RPC is aborted.
Returns:
-
(::Google::Cloud::Spanner::V1::Session)
-
Other tags:
- Yieldparam: operation -
Yieldparam: response -
Other tags:
- Yield: - Access the result along with the RPC operation
Parameters:
-
session
(::Google::Cloud::Spanner::V1::Session, ::Hash
) -- -
database
(::String
) -- -
options
(::Gapic::CallOptions, ::Hash
) -- -
request
(::Google::Cloud::Spanner::V1::CreateSessionRequest, ::Hash
) --
Overloads:
-
create_session(database: nil, session: nil)
-
create_session(request, options = nil)
def create_session request, options = nil raise ::ArgumentError, "request must be provided" if request.nil? request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Spanner::V1::CreateSessionRequest # 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 metadata = @config.rpcs.create_session.metadata.to_h # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \ lib_name: @config.lib_name, lib_version: @config.lib_version, gapic_version: ::Google::Cloud::Spanner::V1::VERSION metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty? metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id header_params = {} if request.database header_params["database"] = request.database end request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&") metadata[:"x-goog-request-params"] ||= request_params_header options.apply_defaults timeout: @config.rpcs.create_session.timeout, metadata: metadata, retry_policy: @config.rpcs.create_session.retry_policy options.apply_defaults timeout: @config.timeout, metadata: @config.metadata, retry_policy: @config.retry_policy @spanner_stub.call_rpc :create_session, request, options: options do |response, operation| yield response, operation if block_given? end rescue ::GRPC::BadStatus => e raise ::Google::Cloud::Error.from_error(e) end
def delete_session request, options = nil
- Example: Basic example -
Raises:
-
(::Google::Cloud::Error)
- if the RPC is aborted.
Returns:
-
(::Google::Protobuf::Empty)
-
Other tags:
- Yieldparam: operation -
Yieldparam: response -
Other tags:
- Yield: - Access the result along with the RPC operation
Parameters:
-
name
(::String
) -- -
options
(::Gapic::CallOptions, ::Hash
) -- -
request
(::Google::Cloud::Spanner::V1::DeleteSessionRequest, ::Hash
) --
Overloads:
-
delete_session(name: nil)
-
delete_session(request, options = nil)
def delete_session request, options = nil raise ::ArgumentError, "request must be provided" if request.nil? request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Spanner::V1::DeleteSessionRequest # 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 metadata = @config.rpcs.delete_session.metadata.to_h # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \ lib_name: @config.lib_name, lib_version: @config.lib_version, gapic_version: ::Google::Cloud::Spanner::V1::VERSION metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty? metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id header_params = {} if request.name header_params["name"] = request.name end request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&") metadata[:"x-goog-request-params"] ||= request_params_header options.apply_defaults timeout: @config.rpcs.delete_session.timeout, metadata: metadata, retry_policy: @config.rpcs.delete_session.retry_policy options.apply_defaults timeout: @config.timeout, metadata: @config.metadata, retry_policy: @config.retry_policy @spanner_stub.call_rpc :delete_session, request, options: options do |response, operation| yield response, operation if block_given? end rescue ::GRPC::BadStatus => e raise ::Google::Cloud::Error.from_error(e) end
def execute_batch_dml request, options = nil
- Example: Basic example -
Raises:
-
(::Google::Cloud::Error)
- if the RPC is aborted.
Returns:
-
(::Google::Cloud::Spanner::V1::ExecuteBatchDmlResponse)
-
Other tags:
- Yieldparam: operation -
Yieldparam: response -
Other tags:
- Yield: - Access the result along with the RPC operation
Parameters:
-
last_statements
(::Boolean
) -- -
request_options
(::Google::Cloud::Spanner::V1::RequestOptions, ::Hash
) -- -
seqno
(::Integer
) -- -
statements
(::Array<::Google::Cloud::Spanner::V1::ExecuteBatchDmlRequest::Statement, ::Hash>
) -- -
transaction
(::Google::Cloud::Spanner::V1::TransactionSelector, ::Hash
) -- -
session
(::String
) -- -
options
(::Gapic::CallOptions, ::Hash
) -- -
request
(::Google::Cloud::Spanner::V1::ExecuteBatchDmlRequest, ::Hash
) --
Overloads:
-
execute_batch_dml(session: nil, transaction: nil, statements: nil, seqno: nil, request_options: nil, last_statements: nil)
-
execute_batch_dml(request, options = nil)
def execute_batch_dml request, options = nil raise ::ArgumentError, "request must be provided" if request.nil? request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Spanner::V1::ExecuteBatchDmlRequest # 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 metadata = @config.rpcs.execute_batch_dml.metadata.to_h # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \ lib_name: @config.lib_name, lib_version: @config.lib_version, gapic_version: ::Google::Cloud::Spanner::V1::VERSION metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty? metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id header_params = {} if request.session header_params["session"] = request.session end request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&") metadata[:"x-goog-request-params"] ||= request_params_header options.apply_defaults timeout: @config.rpcs.execute_batch_dml.timeout, metadata: metadata, retry_policy: @config.rpcs.execute_batch_dml.retry_policy options.apply_defaults timeout: @config.timeout, metadata: @config.metadata, retry_policy: @config.retry_policy @spanner_stub.call_rpc :execute_batch_dml, request, options: options do |response, operation| yield response, operation if block_given? end rescue ::GRPC::BadStatus => e raise ::Google::Cloud::Error.from_error(e) end
def execute_sql request, options = nil
- Example: Basic example -
Raises:
-
(::Google::Cloud::Error)
- if the RPC is aborted.
Returns:
-
(::Google::Cloud::Spanner::V1::ResultSet)
-
Other tags:
- Yieldparam: operation -
Yieldparam: response -
Other tags:
- Yield: - Access the result along with the RPC operation
Parameters:
-
last_statement
(::Boolean
) -- -
data_boost_enabled
(::Boolean
) -- -
directed_read_options
(::Google::Cloud::Spanner::V1::DirectedReadOptions, ::Hash
) -- -
request_options
(::Google::Cloud::Spanner::V1::RequestOptions, ::Hash
) -- -
query_options
(::Google::Cloud::Spanner::V1::ExecuteSqlRequest::QueryOptions, ::Hash
) -- -
seqno
(::Integer
) -- -
partition_token
(::String
) -- -
query_mode
(::Google::Cloud::Spanner::V1::ExecuteSqlRequest::QueryMode
) -- -
resume_token
(::String
) -- -
param_types
(::Hash{::String => ::Google::Cloud::Spanner::V1::Type, ::Hash}
) -- -
params
(::Google::Protobuf::Struct, ::Hash
) -- -
sql
(::String
) -- -
transaction
(::Google::Cloud::Spanner::V1::TransactionSelector, ::Hash
) -- -
session
(::String
) -- -
options
(::Gapic::CallOptions, ::Hash
) -- -
request
(::Google::Cloud::Spanner::V1::ExecuteSqlRequest, ::Hash
) --
Overloads:
-
execute_sql(session: nil, transaction: nil, sql: nil, params: nil, param_types: nil, resume_token: nil, query_mode: nil, partition_token: nil, seqno: nil, query_options: nil, request_options: nil, directed_read_options: nil, data_boost_enabled: nil, last_statement: nil)
-
execute_sql(request, options = nil)
def execute_sql request, options = nil raise ::ArgumentError, "request must be provided" if request.nil? request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Spanner::V1::ExecuteSqlRequest # 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 metadata = @config.rpcs.execute_sql.metadata.to_h # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \ lib_name: @config.lib_name, lib_version: @config.lib_version, gapic_version: ::Google::Cloud::Spanner::V1::VERSION metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty? metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id header_params = {} if request.session header_params["session"] = request.session end request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&") metadata[:"x-goog-request-params"] ||= request_params_header options.apply_defaults timeout: @config.rpcs.execute_sql.timeout, metadata: metadata, retry_policy: @config.rpcs.execute_sql.retry_policy options.apply_defaults timeout: @config.timeout, metadata: @config.metadata, retry_policy: @config.retry_policy @spanner_stub.call_rpc :execute_sql, request, options: options do |response, operation| yield response, operation if block_given? end rescue ::GRPC::BadStatus => e raise ::Google::Cloud::Error.from_error(e) end
def execute_streaming_sql request, options = nil
- Example: Basic example -
Raises:
-
(::Google::Cloud::Error)
- if the RPC is aborted.
Returns:
-
(::Enumerable<::Google::Cloud::Spanner::V1::PartialResultSet>)
-
Other tags:
- Yieldparam: operation -
Yieldparam: response -
Other tags:
- Yield: - Access the result along with the RPC operation
Parameters:
-
last_statement
(::Boolean
) -- -
data_boost_enabled
(::Boolean
) -- -
directed_read_options
(::Google::Cloud::Spanner::V1::DirectedReadOptions, ::Hash
) -- -
request_options
(::Google::Cloud::Spanner::V1::RequestOptions, ::Hash
) -- -
query_options
(::Google::Cloud::Spanner::V1::ExecuteSqlRequest::QueryOptions, ::Hash
) -- -
seqno
(::Integer
) -- -
partition_token
(::String
) -- -
query_mode
(::Google::Cloud::Spanner::V1::ExecuteSqlRequest::QueryMode
) -- -
resume_token
(::String
) -- -
param_types
(::Hash{::String => ::Google::Cloud::Spanner::V1::Type, ::Hash}
) -- -
params
(::Google::Protobuf::Struct, ::Hash
) -- -
sql
(::String
) -- -
transaction
(::Google::Cloud::Spanner::V1::TransactionSelector, ::Hash
) -- -
session
(::String
) -- -
options
(::Gapic::CallOptions, ::Hash
) -- -
request
(::Google::Cloud::Spanner::V1::ExecuteSqlRequest, ::Hash
) --
Overloads:
-
execute_streaming_sql(session: nil, transaction: nil, sql: nil, params: nil, param_types: nil, resume_token: nil, query_mode: nil, partition_token: nil, seqno: nil, query_options: nil, request_options: nil, directed_read_options: nil, data_boost_enabled: nil, last_statement: nil)
-
execute_streaming_sql(request, options = nil)
def execute_streaming_sql request, options = nil raise ::ArgumentError, "request must be provided" if request.nil? request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Spanner::V1::ExecuteSqlRequest # 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 metadata = @config.rpcs.execute_streaming_sql.metadata.to_h # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \ lib_name: @config.lib_name, lib_version: @config.lib_version, gapic_version: ::Google::Cloud::Spanner::V1::VERSION metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty? metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id header_params = {} if request.session header_params["session"] = request.session end request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&") metadata[:"x-goog-request-params"] ||= request_params_header options.apply_defaults timeout: @config.rpcs.execute_streaming_sql.timeout, metadata: metadata, retry_policy: @config.rpcs.execute_streaming_sql.retry_policy options.apply_defaults timeout: @config.timeout, metadata: @config.metadata, retry_policy: @config.retry_policy @spanner_stub.call_rpc :execute_streaming_sql, request, options: options do |response, operation| yield response, operation if block_given? end rescue ::GRPC::BadStatus => e raise ::Google::Cloud::Error.from_error(e) end
def get_session request, options = nil
- Example: Basic example -
Raises:
-
(::Google::Cloud::Error)
- if the RPC is aborted.
Returns:
-
(::Google::Cloud::Spanner::V1::Session)
-
Other tags:
- Yieldparam: operation -
Yieldparam: response -
Other tags:
- Yield: - Access the result along with the RPC operation
Parameters:
-
name
(::String
) -- -
options
(::Gapic::CallOptions, ::Hash
) -- -
request
(::Google::Cloud::Spanner::V1::GetSessionRequest, ::Hash
) --
Overloads:
-
get_session(name: nil)
-
get_session(request, options = nil)
def get_session request, options = nil raise ::ArgumentError, "request must be provided" if request.nil? request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Spanner::V1::GetSessionRequest # 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 metadata = @config.rpcs.get_session.metadata.to_h # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \ lib_name: @config.lib_name, lib_version: @config.lib_version, gapic_version: ::Google::Cloud::Spanner::V1::VERSION metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty? metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id header_params = {} if request.name header_params["name"] = request.name end request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&") metadata[:"x-goog-request-params"] ||= request_params_header options.apply_defaults timeout: @config.rpcs.get_session.timeout, metadata: metadata, retry_policy: @config.rpcs.get_session.retry_policy options.apply_defaults timeout: @config.timeout, metadata: @config.metadata, retry_policy: @config.retry_policy @spanner_stub.call_rpc :get_session, request, options: options do |response, operation| yield response, operation if block_given? end rescue ::GRPC::BadStatus => e raise ::Google::Cloud::Error.from_error(e) end
def initialize
- Yieldparam: config -
Other tags:
- Yield: - Configure the Spanner client.
def initialize # These require statements are intentionally placed here to initialize # the gRPC module only when it's required. # See https://github.com/googleapis/toolkit/issues/446 require "gapic/grpc" require "google/spanner/v1/spanner_services_pb" # 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 @spanner_stub = ::Gapic::ServiceStub.new( ::Google::Cloud::Spanner::V1::Spanner::Stub, credentials: credentials, endpoint: @config.endpoint, endpoint_template: DEFAULT_ENDPOINT_TEMPLATE, universe_domain: @config.universe_domain, channel_args: @config.channel_args, interceptors: @config.interceptors, channel_pool_config: @config.channel_pool, logger: @config.logger ) @spanner_stub.stub_logger&.info do |entry| entry.set_system_name entry.set_service entry.message = "Created client for #{entry.service}" entry.set_credentials_fields credentials entry.set "customEndpoint", @config.endpoint if @config.endpoint entry.set "defaultTimeout", @config.timeout if @config.timeout entry.set "quotaProject", @quota_project_id if @quota_project_id end end
def list_sessions request, options = nil
- Example: Basic example -
Raises:
-
(::Google::Cloud::Error)
- if the RPC is aborted.
Returns:
-
(::Gapic::PagedEnumerable<::Google::Cloud::Spanner::V1::Session>)
-
Other tags:
- Yieldparam: operation -
Yieldparam: response -
Other tags:
- Yield: - Access the result along with the RPC operation
Parameters:
-
filter
(::String
) -- -
page_token
(::String
) -- -
page_size
(::Integer
) -- -
database
(::String
) -- -
options
(::Gapic::CallOptions, ::Hash
) -- -
request
(::Google::Cloud::Spanner::V1::ListSessionsRequest, ::Hash
) --
Overloads:
-
list_sessions(database: nil, page_size: nil, page_token: nil, filter: nil)
-
list_sessions(request, options = nil)
def list_sessions request, options = nil raise ::ArgumentError, "request must be provided" if request.nil? request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Spanner::V1::ListSessionsRequest # 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 metadata = @config.rpcs.list_sessions.metadata.to_h # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \ lib_name: @config.lib_name, lib_version: @config.lib_version, gapic_version: ::Google::Cloud::Spanner::V1::VERSION metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty? metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id header_params = {} if request.database header_params["database"] = request.database end request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&") metadata[:"x-goog-request-params"] ||= request_params_header options.apply_defaults timeout: @config.rpcs.list_sessions.timeout, metadata: metadata, retry_policy: @config.rpcs.list_sessions.retry_policy options.apply_defaults timeout: @config.timeout, metadata: @config.metadata, retry_policy: @config.retry_policy @spanner_stub.call_rpc :list_sessions, request, options: options do |response, operation| response = ::Gapic::PagedEnumerable.new @spanner_stub, :list_sessions, request, response, operation, options yield response, operation if block_given? throw :response, response end rescue ::GRPC::BadStatus => e raise ::Google::Cloud::Error.from_error(e) end
def logger
-
(Logger)
-
def logger @spanner_stub.logger end
def partition_query request, options = nil
- Example: Basic example -
Raises:
-
(::Google::Cloud::Error)
- if the RPC is aborted.
Returns:
-
(::Google::Cloud::Spanner::V1::PartitionResponse)
-
Other tags:
- Yieldparam: operation -
Yieldparam: response -
Other tags:
- Yield: - Access the result along with the RPC operation
Parameters:
-
partition_options
(::Google::Cloud::Spanner::V1::PartitionOptions, ::Hash
) -- -
param_types
(::Hash{::String => ::Google::Cloud::Spanner::V1::Type, ::Hash}
) -- -
params
(::Google::Protobuf::Struct, ::Hash
) -- -
sql
(::String
) -- -
transaction
(::Google::Cloud::Spanner::V1::TransactionSelector, ::Hash
) -- -
session
(::String
) -- -
options
(::Gapic::CallOptions, ::Hash
) -- -
request
(::Google::Cloud::Spanner::V1::PartitionQueryRequest, ::Hash
) --
Overloads:
-
partition_query(session: nil, transaction: nil, sql: nil, params: nil, param_types: nil, partition_options: nil)
-
partition_query(request, options = nil)
def partition_query request, options = nil raise ::ArgumentError, "request must be provided" if request.nil? request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Spanner::V1::PartitionQueryRequest # 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 metadata = @config.rpcs.partition_query.metadata.to_h # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \ lib_name: @config.lib_name, lib_version: @config.lib_version, gapic_version: ::Google::Cloud::Spanner::V1::VERSION metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty? metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id header_params = {} if request.session header_params["session"] = request.session end request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&") metadata[:"x-goog-request-params"] ||= request_params_header options.apply_defaults timeout: @config.rpcs.partition_query.timeout, metadata: metadata, retry_policy: @config.rpcs.partition_query.retry_policy options.apply_defaults timeout: @config.timeout, metadata: @config.metadata, retry_policy: @config.retry_policy @spanner_stub.call_rpc :partition_query, request, options: options do |response, operation| yield response, operation if block_given? end rescue ::GRPC::BadStatus => e raise ::Google::Cloud::Error.from_error(e) end
def partition_read request, options = nil
- Example: Basic example -
Raises:
-
(::Google::Cloud::Error)
- if the RPC is aborted.
Returns:
-
(::Google::Cloud::Spanner::V1::PartitionResponse)
-
Other tags:
- Yieldparam: operation -
Yieldparam: response -
Other tags:
- Yield: - Access the result along with the RPC operation
Parameters:
-
partition_options
(::Google::Cloud::Spanner::V1::PartitionOptions, ::Hash
) -- -
key_set
(::Google::Cloud::Spanner::V1::KeySet, ::Hash
) -- -
columns
(::Array<::String>
) -- -
index
(::String
) -- -
table
(::String
) -- -
transaction
(::Google::Cloud::Spanner::V1::TransactionSelector, ::Hash
) -- -
session
(::String
) -- -
options
(::Gapic::CallOptions, ::Hash
) -- -
request
(::Google::Cloud::Spanner::V1::PartitionReadRequest, ::Hash
) --
Overloads:
-
partition_read(session: nil, transaction: nil, table: nil, index: nil, columns: nil, key_set: nil, partition_options: nil)
-
partition_read(request, options = nil)
def partition_read request, options = nil raise ::ArgumentError, "request must be provided" if request.nil? request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Spanner::V1::PartitionReadRequest # 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 metadata = @config.rpcs.partition_read.metadata.to_h # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \ lib_name: @config.lib_name, lib_version: @config.lib_version, gapic_version: ::Google::Cloud::Spanner::V1::VERSION metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty? metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id header_params = {} if request.session header_params["session"] = request.session end request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&") metadata[:"x-goog-request-params"] ||= request_params_header options.apply_defaults timeout: @config.rpcs.partition_read.timeout, metadata: metadata, retry_policy: @config.rpcs.partition_read.retry_policy options.apply_defaults timeout: @config.timeout, metadata: @config.metadata, retry_policy: @config.retry_policy @spanner_stub.call_rpc :partition_read, request, options: options do |response, operation| yield response, operation if block_given? end rescue ::GRPC::BadStatus => e raise ::Google::Cloud::Error.from_error(e) end
def read request, options = nil
- Example: Basic example -
Raises:
-
(::Google::Cloud::Error)
- if the RPC is aborted.
Returns:
-
(::Google::Cloud::Spanner::V1::ResultSet)
-
Other tags:
- Yieldparam: operation -
Yieldparam: response -
Other tags:
- Yield: - Access the result along with the RPC operation
Parameters:
-
lock_hint
(::Google::Cloud::Spanner::V1::ReadRequest::LockHint
) -- -
order_by
(::Google::Cloud::Spanner::V1::ReadRequest::OrderBy
) -- -
data_boost_enabled
(::Boolean
) -- -
directed_read_options
(::Google::Cloud::Spanner::V1::DirectedReadOptions, ::Hash
) -- -
request_options
(::Google::Cloud::Spanner::V1::RequestOptions, ::Hash
) -- -
partition_token
(::String
) -- -
resume_token
(::String
) -- -
limit
(::Integer
) -- -
key_set
(::Google::Cloud::Spanner::V1::KeySet, ::Hash
) -- -
columns
(::Array<::String>
) -- -
index
(::String
) -- -
table
(::String
) -- -
transaction
(::Google::Cloud::Spanner::V1::TransactionSelector, ::Hash
) -- -
session
(::String
) -- -
options
(::Gapic::CallOptions, ::Hash
) -- -
request
(::Google::Cloud::Spanner::V1::ReadRequest, ::Hash
) --
Overloads:
-
read(session: nil, transaction: nil, table: nil, index: nil, columns: nil, key_set: nil, limit: nil, resume_token: nil, partition_token: nil, request_options: nil, directed_read_options: nil, data_boost_enabled: nil, order_by: nil, lock_hint: nil)
-
read(request, options = nil)
def read request, options = nil raise ::ArgumentError, "request must be provided" if request.nil? request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Spanner::V1::ReadRequest # 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 metadata = @config.rpcs.read.metadata.to_h # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \ lib_name: @config.lib_name, lib_version: @config.lib_version, gapic_version: ::Google::Cloud::Spanner::V1::VERSION metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty? metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id header_params = {} if request.session header_params["session"] = request.session end request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&") metadata[:"x-goog-request-params"] ||= request_params_header options.apply_defaults timeout: @config.rpcs.read.timeout, metadata: metadata, retry_policy: @config.rpcs.read.retry_policy options.apply_defaults timeout: @config.timeout, metadata: @config.metadata, retry_policy: @config.retry_policy @spanner_stub.call_rpc :read, request, options: options do |response, operation| yield response, operation if block_given? end rescue ::GRPC::BadStatus => e raise ::Google::Cloud::Error.from_error(e) end
def rollback request, options = nil
- Example: Basic example -
Raises:
-
(::Google::Cloud::Error)
- if the RPC is aborted.
Returns:
-
(::Google::Protobuf::Empty)
-
Other tags:
- Yieldparam: operation -
Yieldparam: response -
Other tags:
- Yield: - Access the result along with the RPC operation
Parameters:
-
transaction_id
(::String
) -- -
session
(::String
) -- -
options
(::Gapic::CallOptions, ::Hash
) -- -
request
(::Google::Cloud::Spanner::V1::RollbackRequest, ::Hash
) --
Overloads:
-
rollback(session: nil, transaction_id: nil)
-
rollback(request, options = nil)
def rollback request, options = nil raise ::ArgumentError, "request must be provided" if request.nil? request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Spanner::V1::RollbackRequest # 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 metadata = @config.rpcs.rollback.metadata.to_h # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \ lib_name: @config.lib_name, lib_version: @config.lib_version, gapic_version: ::Google::Cloud::Spanner::V1::VERSION metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty? metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id header_params = {} if request.session header_params["session"] = request.session end request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&") metadata[:"x-goog-request-params"] ||= request_params_header options.apply_defaults timeout: @config.rpcs.rollback.timeout, metadata: metadata, retry_policy: @config.rpcs.rollback.retry_policy options.apply_defaults timeout: @config.timeout, metadata: @config.metadata, retry_policy: @config.retry_policy @spanner_stub.call_rpc :rollback, request, options: options do |response, operation| yield response, operation if block_given? end rescue ::GRPC::BadStatus => e raise ::Google::Cloud::Error.from_error(e) end
def streaming_read request, options = nil
- Example: Basic example -
Raises:
-
(::Google::Cloud::Error)
- if the RPC is aborted.
Returns:
-
(::Enumerable<::Google::Cloud::Spanner::V1::PartialResultSet>)
-
Other tags:
- Yieldparam: operation -
Yieldparam: response -
Other tags:
- Yield: - Access the result along with the RPC operation
Parameters:
-
lock_hint
(::Google::Cloud::Spanner::V1::ReadRequest::LockHint
) -- -
order_by
(::Google::Cloud::Spanner::V1::ReadRequest::OrderBy
) -- -
data_boost_enabled
(::Boolean
) -- -
directed_read_options
(::Google::Cloud::Spanner::V1::DirectedReadOptions, ::Hash
) -- -
request_options
(::Google::Cloud::Spanner::V1::RequestOptions, ::Hash
) -- -
partition_token
(::String
) -- -
resume_token
(::String
) -- -
limit
(::Integer
) -- -
key_set
(::Google::Cloud::Spanner::V1::KeySet, ::Hash
) -- -
columns
(::Array<::String>
) -- -
index
(::String
) -- -
table
(::String
) -- -
transaction
(::Google::Cloud::Spanner::V1::TransactionSelector, ::Hash
) -- -
session
(::String
) -- -
options
(::Gapic::CallOptions, ::Hash
) -- -
request
(::Google::Cloud::Spanner::V1::ReadRequest, ::Hash
) --
Overloads:
-
streaming_read(session: nil, transaction: nil, table: nil, index: nil, columns: nil, key_set: nil, limit: nil, resume_token: nil, partition_token: nil, request_options: nil, directed_read_options: nil, data_boost_enabled: nil, order_by: nil, lock_hint: nil)
-
streaming_read(request, options = nil)
def streaming_read request, options = nil raise ::ArgumentError, "request must be provided" if request.nil? request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Spanner::V1::ReadRequest # 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 metadata = @config.rpcs.streaming_read.metadata.to_h # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \ lib_name: @config.lib_name, lib_version: @config.lib_version, gapic_version: ::Google::Cloud::Spanner::V1::VERSION metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty? metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id header_params = {} if request.session header_params["session"] = request.session end request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&") metadata[:"x-goog-request-params"] ||= request_params_header options.apply_defaults timeout: @config.rpcs.streaming_read.timeout, metadata: metadata, retry_policy: @config.rpcs.streaming_read.retry_policy options.apply_defaults timeout: @config.timeout, metadata: @config.metadata, retry_policy: @config.retry_policy @spanner_stub.call_rpc :streaming_read, request, options: options do |response, operation| yield response, operation if block_given? end rescue ::GRPC::BadStatus => e raise ::Google::Cloud::Error.from_error(e) end
def universe_domain
-
(String)
-
def universe_domain @spanner_stub.universe_domain end