google-cloud-spanner 1.6.1 → 1.6.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/google-cloud-spanner.rb +5 -4
- data/lib/google/cloud/spanner.rb +2 -346
- data/lib/google/cloud/spanner/admin/database.rb +39 -3
- data/lib/google/cloud/spanner/admin/database/credentials.rb +5 -9
- data/lib/google/cloud/spanner/admin/database/v1.rb +69 -28
- data/lib/google/cloud/spanner/admin/database/v1/credentials.rb +46 -0
- data/lib/google/cloud/spanner/admin/database/v1/database_admin_client.rb +111 -53
- data/lib/google/cloud/spanner/admin/database/v1/doc/google/iam/v1/iam_policy.rb +63 -0
- data/lib/google/cloud/spanner/admin/database/v1/doc/google/iam/v1/policy.rb +8 -19
- data/lib/google/cloud/spanner/admin/database/v1/doc/google/longrunning/operations.rb +93 -0
- data/lib/google/cloud/spanner/admin/database/v1/doc/google/protobuf/any.rb +15 -9
- data/lib/google/cloud/spanner/admin/database/v1/doc/google/protobuf/empty.rb +29 -0
- data/lib/google/cloud/spanner/admin/database/v1/doc/google/rpc/status.rb +2 -1
- data/lib/google/cloud/spanner/admin/database/v1/doc/google/spanner/admin/database/v1/spanner_database_admin.rb +2 -12
- data/lib/google/cloud/spanner/admin/instance.rb +39 -3
- data/lib/google/cloud/spanner/admin/instance/credentials.rb +5 -9
- data/lib/google/cloud/spanner/admin/instance/v1.rb +69 -28
- data/lib/google/cloud/spanner/admin/instance/v1/credentials.rb +46 -0
- data/lib/google/cloud/spanner/admin/instance/v1/doc/google/iam/v1/iam_policy.rb +63 -0
- data/lib/google/cloud/spanner/admin/instance/v1/doc/google/iam/v1/policy.rb +8 -19
- data/lib/google/cloud/spanner/admin/instance/v1/doc/google/longrunning/operations.rb +93 -0
- data/lib/google/cloud/spanner/admin/instance/v1/doc/google/protobuf/any.rb +15 -9
- data/lib/google/cloud/spanner/admin/instance/v1/doc/google/protobuf/empty.rb +29 -0
- data/lib/google/cloud/spanner/admin/instance/v1/doc/google/protobuf/field_mask.rb +8 -1
- data/lib/google/cloud/spanner/admin/instance/v1/doc/google/rpc/status.rb +2 -1
- data/lib/google/cloud/spanner/admin/instance/v1/doc/google/spanner/admin/instance/v1/spanner_instance_admin.rb +2 -12
- data/lib/google/cloud/spanner/admin/instance/v1/instance_admin_client.rb +125 -58
- data/lib/google/cloud/spanner/database/job.rb +1 -0
- data/lib/google/cloud/spanner/instance/job.rb +1 -0
- data/lib/google/cloud/spanner/v1/credentials.rb +1 -0
- data/lib/google/cloud/spanner/v1/doc/google/protobuf/duration.rb +1 -0
- data/lib/google/cloud/spanner/v1/doc/google/protobuf/empty.rb +1 -0
- data/lib/google/cloud/spanner/v1/doc/google/protobuf/struct.rb +1 -0
- data/lib/google/cloud/spanner/v1/doc/google/protobuf/timestamp.rb +9 -6
- data/lib/google/cloud/spanner/v1/doc/google/spanner/v1/keys.rb +1 -0
- data/lib/google/cloud/spanner/v1/doc/google/spanner/v1/mutation.rb +1 -0
- data/lib/google/cloud/spanner/v1/doc/google/spanner/v1/query_plan.rb +1 -0
- data/lib/google/cloud/spanner/v1/doc/google/spanner/v1/result_set.rb +1 -0
- data/lib/google/cloud/spanner/v1/doc/google/spanner/v1/spanner.rb +1 -0
- data/lib/google/cloud/spanner/v1/doc/google/spanner/v1/transaction.rb +1 -0
- data/lib/google/cloud/spanner/v1/doc/google/spanner/v1/type.rb +1 -0
- data/lib/google/cloud/spanner/v1/spanner_client.rb +28 -26
- data/lib/google/cloud/spanner/version.rb +1 -1
- data/lib/google/spanner/admin/database/v1/spanner_database_admin_pb.rb +1 -1
- data/lib/google/spanner/admin/database/v1/spanner_database_admin_services_pb.rb +3 -2
- data/lib/google/spanner/admin/instance/v1/spanner_instance_admin_pb.rb +1 -1
- data/lib/google/spanner/admin/instance/v1/spanner_instance_admin_services_pb.rb +3 -2
- data/lib/google/spanner/v1/keys_pb.rb +1 -0
- data/lib/google/spanner/v1/mutation_pb.rb +1 -0
- data/lib/google/spanner/v1/query_plan_pb.rb +1 -0
- data/lib/google/spanner/v1/result_set_pb.rb +1 -0
- data/lib/google/spanner/v1/spanner_pb.rb +1 -0
- data/lib/google/spanner/v1/spanner_services_pb.rb +1 -0
- data/lib/google/spanner/v1/transaction_pb.rb +1 -0
- data/lib/google/spanner/v1/type_pb.rb +1 -0
- metadata +14 -8
- data/lib/google/cloud/spanner/admin/database/v1/doc/overview.rb +0 -58
- data/lib/google/cloud/spanner/admin/instance/v1/doc/overview.rb +0 -58
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 554678bfa633745cd0aa9c547791adff72c5bae2ce3d213cecd0282f2ae225a6
|
4
|
+
data.tar.gz: 57db3883a4deea6fb737c268948814a7ce9327c2e0ddf63d93844e29a7cd3303
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8439f0275421349e0515c64977f97e1ef71666396a7a23cdf00ce039128c2195df3347315ab01415b39e83e80736b77b0c716e6991c3c30fff575072bcadb327
|
7
|
+
data.tar.gz: ac6373f64013c739157cf3cd664a80585d3b3f9c9bafb805619de7bb748a4b205cabc649009d27fa763106710194889547ab46a7b366d7522da318d0c0d3b8e9
|
data/lib/google-cloud-spanner.rb
CHANGED
@@ -12,6 +12,7 @@
|
|
12
12
|
# See the License for the specific language governing permissions and
|
13
13
|
# limitations under the License.
|
14
14
|
|
15
|
+
|
15
16
|
##
|
16
17
|
# This file is here to be autorequired by bundler, so that the
|
17
18
|
# Google::Cloud.spanner and Google::Cloud#spanner methods can be available, but
|
@@ -29,8 +30,8 @@ module Google
|
|
29
30
|
# Creates a new object for connecting to the Spanner service.
|
30
31
|
# Each call creates a new connection.
|
31
32
|
#
|
32
|
-
# For more information on connecting to Google Cloud see the
|
33
|
-
# Guide
|
33
|
+
# For more information on connecting to Google Cloud see the
|
34
|
+
# {file:AUTHENTICATION.md Authentication Guide}.
|
34
35
|
#
|
35
36
|
# @param [String, Array<String>] scope The OAuth 2.0 scopes controlling the
|
36
37
|
# set of resources and operations that the connection can access. See
|
@@ -70,8 +71,8 @@ module Google
|
|
70
71
|
# Creates a new object for connecting to the Spanner service.
|
71
72
|
# Each call creates a new connection.
|
72
73
|
#
|
73
|
-
# For more information on connecting to Google Cloud see the
|
74
|
-
# Guide
|
74
|
+
# For more information on connecting to Google Cloud see the
|
75
|
+
# {file:AUTHENTICATION.md Authentication Guide}.
|
75
76
|
#
|
76
77
|
# @param [String] project_id Project identifier for the Spanner service you
|
77
78
|
# are connecting to. If not present, the default project for the
|
data/lib/google/cloud/spanner.rb
CHANGED
@@ -31,350 +31,7 @@ module Google
|
|
31
31
|
# For more information about Cloud Spanner, read the [Cloud
|
32
32
|
# Spanner Documentation](https://cloud.google.com/spanner/docs/).
|
33
33
|
#
|
34
|
-
#
|
35
|
-
# Rubyists. Your authentication credentials are detected automatically in
|
36
|
-
# Google Cloud Platform environments such as Google Compute Engine, Google
|
37
|
-
# App Engine and Google Kubernetes Engine. In other environments you can
|
38
|
-
# configure authentication easily, either directly in your code or via
|
39
|
-
# environment variables. Read more about the options for connecting in the
|
40
|
-
# [Authentication
|
41
|
-
# Guide](https://googlecloudplatform.github.io/google-cloud-ruby/#/docs/guides/authentication).
|
42
|
-
#
|
43
|
-
# ## Enabling Logging
|
44
|
-
#
|
45
|
-
# To enable logging for this library, set the logger for the underlying
|
46
|
-
# [gRPC](https://github.com/grpc/grpc/tree/master/src/ruby) library. The
|
47
|
-
# logger that you set may be a Ruby stdlib
|
48
|
-
# [`Logger`](https://ruby-doc.org/stdlib-2.5.0/libdoc/logger/rdoc/Logger.html)
|
49
|
-
# as shown below, or a
|
50
|
-
# [`Google::Cloud::Logging::Logger`](https://googlecloudplatform.github.io/google-cloud-ruby/#/docs/google-cloud-logging/latest/google/cloud/logging/logger)
|
51
|
-
# that will write logs to [Stackdriver
|
52
|
-
# Logging](https://cloud.google.com/logging/). See
|
53
|
-
# [grpc/logconfig.rb](https://github.com/grpc/grpc/blob/master/src/ruby/lib/grpc/logconfig.rb)
|
54
|
-
# and the gRPC
|
55
|
-
# [spec_helper.rb](https://github.com/grpc/grpc/blob/master/src/ruby/spec/spec_helper.rb)
|
56
|
-
# for additional information.
|
57
|
-
#
|
58
|
-
# Configuring a Ruby stdlib logger:
|
59
|
-
#
|
60
|
-
# ```ruby
|
61
|
-
# require "logger"
|
62
|
-
#
|
63
|
-
# module MyLogger
|
64
|
-
# LOGGER = Logger.new $stderr, level: Logger::WARN
|
65
|
-
# def logger
|
66
|
-
# LOGGER
|
67
|
-
# end
|
68
|
-
# end
|
69
|
-
#
|
70
|
-
# # Define a gRPC module-level logger method before grpc/logconfig.rb loads.
|
71
|
-
# module GRPC
|
72
|
-
# extend MyLogger
|
73
|
-
# end
|
74
|
-
# ```
|
75
|
-
#
|
76
|
-
# ## Creating instances
|
77
|
-
#
|
78
|
-
# When you first use Cloud Spanner, you must create an instance, which is an
|
79
|
-
# allocation of resources that are used by Cloud Spanner databases. When you
|
80
|
-
# create an instance, you choose where your data is stored and how many
|
81
|
-
# nodes are used for your data. (For more information, see [Instance
|
82
|
-
# Configuration](https://cloud.google.com/spanner/docs/instance-configuration)).
|
83
|
-
#
|
84
|
-
# Use {Spanner::Project#create_instance} to create an instance:
|
85
|
-
#
|
86
|
-
# ```ruby
|
87
|
-
# require "google/cloud/spanner"
|
88
|
-
#
|
89
|
-
# spanner = Google::Cloud::Spanner.new
|
90
|
-
#
|
91
|
-
# job = spanner.create_instance "my-instance",
|
92
|
-
# name: "My Instance",
|
93
|
-
# config: "regional-us-central1",
|
94
|
-
# nodes: 5,
|
95
|
-
# labels: { production: :env }
|
96
|
-
#
|
97
|
-
# job.done? #=> false
|
98
|
-
# job.reload! # API call
|
99
|
-
# job.done? #=> true
|
100
|
-
#
|
101
|
-
# if job.error?
|
102
|
-
# status = job.error
|
103
|
-
# else
|
104
|
-
# instance = job.instance
|
105
|
-
# end
|
106
|
-
# ```
|
107
|
-
#
|
108
|
-
# ## Creating databases
|
109
|
-
#
|
110
|
-
# Now that you have created an instance, you can create a database. Cloud
|
111
|
-
# Spanner databases hold the tables and indexes that allow you to read and
|
112
|
-
# write data. You may create multiple databases in an instance.
|
113
|
-
#
|
114
|
-
# Use {Spanner::Project#create_database} (or
|
115
|
-
# {Spanner::Instance#create_database}) to create a database:
|
116
|
-
#
|
117
|
-
# ```ruby
|
118
|
-
# require "google/cloud/spanner"
|
119
|
-
#
|
120
|
-
# spanner = Google::Cloud::Spanner.new
|
121
|
-
#
|
122
|
-
# job = spanner.create_database "my-instance", "my-database"
|
123
|
-
#
|
124
|
-
# job.done? #=> false
|
125
|
-
# job.reload! # API call
|
126
|
-
# job.done? #=> true
|
127
|
-
#
|
128
|
-
# if job.error?
|
129
|
-
# status = job.error
|
130
|
-
# else
|
131
|
-
# database = job.database
|
132
|
-
# end
|
133
|
-
# ```
|
134
|
-
#
|
135
|
-
# ## Updating database schemas
|
136
|
-
#
|
137
|
-
# Cloud Spanner supports schema updates to a database while the database
|
138
|
-
# continues to serve traffic. Schema updates do not require taking the
|
139
|
-
# database offline and they do not lock entire tables or columns; you can
|
140
|
-
# continue writing data to the database during the schema update.
|
141
|
-
#
|
142
|
-
# Use {Spanner::Database#update} to execute one or more statements in Cloud
|
143
|
-
# Spanner's Data Definition Language (DDL):
|
144
|
-
#
|
145
|
-
# ```ruby
|
146
|
-
# require "google/cloud/spanner"
|
147
|
-
#
|
148
|
-
# spanner = Google::Cloud::Spanner.new
|
149
|
-
#
|
150
|
-
# database = spanner.database "my-instance", "my-database"
|
151
|
-
#
|
152
|
-
# add_users_table_sql = %q(
|
153
|
-
# CREATE TABLE users (
|
154
|
-
# id INT64 NOT NULL,
|
155
|
-
# username STRING(25) NOT NULL,
|
156
|
-
# name STRING(45) NOT NULL,
|
157
|
-
# email STRING(128),
|
158
|
-
# ) PRIMARY KEY(id)
|
159
|
-
# )
|
160
|
-
#
|
161
|
-
# database.update statements: [add_users_table_sql]
|
162
|
-
# ```
|
163
|
-
#
|
164
|
-
# ## Creating clients
|
165
|
-
#
|
166
|
-
# In order to read and/or write data, you must create a database client.
|
167
|
-
# You can think of a client as a database connection: All of your
|
168
|
-
# interactions with Cloud Spanner data must go through a client. Typically
|
169
|
-
# you create a client when your application starts up, then you re-use that
|
170
|
-
# client to read, write, and execute transactions.
|
171
|
-
#
|
172
|
-
# Use {Spanner::Project#client} to create a client:
|
173
|
-
#
|
174
|
-
# ```ruby
|
175
|
-
# require "google/cloud/spanner"
|
176
|
-
#
|
177
|
-
# spanner = Google::Cloud::Spanner.new
|
178
|
-
#
|
179
|
-
# db = spanner.client "my-instance", "my-database"
|
180
|
-
#
|
181
|
-
# results = db.execute "SELECT 1"
|
182
|
-
#
|
183
|
-
# results.rows.each do |row|
|
184
|
-
# puts row
|
185
|
-
# end
|
186
|
-
# ```
|
187
|
-
#
|
188
|
-
# ## Writing data
|
189
|
-
#
|
190
|
-
# You write data using your client object. The client object supports
|
191
|
-
# various mutation operations, as well as combinations of inserts, updates,
|
192
|
-
# deletes, etc., that can be applied atomically to different rows and/or
|
193
|
-
# tables in a database.
|
194
|
-
#
|
195
|
-
# Use {Spanner::Client#commit} to execute various mutations atomically at a
|
196
|
-
# single logical point in time. All changes are accumulated in memory until
|
197
|
-
# the block completes. Unlike {Spanner::Client#transaction}, which can also
|
198
|
-
# perform reads, this operation accepts only mutations and makes a single
|
199
|
-
# API request.
|
200
|
-
#
|
201
|
-
# ```ruby
|
202
|
-
# require "google/cloud/spanner"
|
203
|
-
#
|
204
|
-
# spanner = Google::Cloud::Spanner.new
|
205
|
-
#
|
206
|
-
# db = spanner.client "my-instance", "my-database"
|
207
|
-
#
|
208
|
-
# db.commit do |c|
|
209
|
-
# c.update "users", [{ id: 1, username: "charlie94", name: "Charlie" }]
|
210
|
-
# c.insert "users", [{ id: 2, username: "harvey00", name: "Harvey" }]
|
211
|
-
# end
|
212
|
-
# ```
|
213
|
-
#
|
214
|
-
# ## Querying data using SQL
|
215
|
-
#
|
216
|
-
# Cloud Spanner supports a native SQL interface for reading data that is
|
217
|
-
# available through {Spanner::Client#execute}:
|
218
|
-
#
|
219
|
-
# ```ruby
|
220
|
-
# require "google/cloud/spanner"
|
221
|
-
#
|
222
|
-
# spanner = Google::Cloud::Spanner.new
|
223
|
-
#
|
224
|
-
# db = spanner.client "my-instance", "my-database"
|
225
|
-
#
|
226
|
-
# results = db.execute "SELECT * FROM users"
|
227
|
-
#
|
228
|
-
# results.rows.each do |row|
|
229
|
-
# puts "User #{row[:id]} is #{row[:name]}"
|
230
|
-
# end
|
231
|
-
# ```
|
232
|
-
#
|
233
|
-
# ## Reading data using the read method
|
234
|
-
#
|
235
|
-
# In addition to Cloud Spanner's SQL interface, Cloud Spanner also supports
|
236
|
-
# a read interface. Use the {Spanner::Client#read} method to read rows from
|
237
|
-
# the database, and use its `keys` option to pass unique identifiers as both
|
238
|
-
# lists and ranges:
|
239
|
-
#
|
240
|
-
# ```ruby
|
241
|
-
# require "google/cloud/spanner"
|
242
|
-
#
|
243
|
-
# spanner = Google::Cloud::Spanner.new
|
244
|
-
#
|
245
|
-
# db = spanner.client "my-instance", "my-database"
|
246
|
-
#
|
247
|
-
# results = db.read "users", [:id, :name], keys: 1..5
|
248
|
-
#
|
249
|
-
# results.rows.each do |row|
|
250
|
-
# puts "User #{row[:id]} is #{row[:name]}"
|
251
|
-
# end
|
252
|
-
# ```
|
253
|
-
#
|
254
|
-
# ## Using read-write transactions
|
255
|
-
#
|
256
|
-
# When an operation might write data depending on values it reads, you
|
257
|
-
# should use a read-write transaction to perform the reads and writes
|
258
|
-
# atomically.
|
259
|
-
#
|
260
|
-
# Suppose that sales of `Albums(1, 1)` are lower than expected and you want
|
261
|
-
# to move $200,000 from the marketing budget of `Albums(2, 2)` to it, but
|
262
|
-
# only if the budget of `Albums(2, 2)` is at least $300,000.
|
263
|
-
#
|
264
|
-
# Use {Spanner::Client#transaction} to execute both reads and writes
|
265
|
-
# atomically at a single logical point in time. All changes are accumulated
|
266
|
-
# in memory until the block completes. Transactions will be automatically
|
267
|
-
# retried when possible. This operation makes separate API requests to begin
|
268
|
-
# and commit the transaction.
|
269
|
-
#
|
270
|
-
# ```ruby
|
271
|
-
# require "google/cloud/spanner"
|
272
|
-
#
|
273
|
-
# spanner = Google::Cloud::Spanner.new
|
274
|
-
#
|
275
|
-
# db = spanner.client "my-instance", "my-database"
|
276
|
-
#
|
277
|
-
# db.transaction do |tx|
|
278
|
-
# # Read the second album budget.
|
279
|
-
# second_album_result = tx.read "Albums", ["marketing_budget"],
|
280
|
-
# keys: [[2, 2]], limit: 1
|
281
|
-
# second_album_row = second_album_result.rows.first
|
282
|
-
# second_album_budget = second_album_row.values.first
|
283
|
-
#
|
284
|
-
# transfer_amount = 200000
|
285
|
-
#
|
286
|
-
# if second_album_budget < 300000
|
287
|
-
# # Raising an exception will automatically roll back the transaction.
|
288
|
-
# raise "The second album doesn't have enough funds to transfer"
|
289
|
-
# end
|
290
|
-
#
|
291
|
-
# # Read the first album's budget.
|
292
|
-
# first_album_result = tx.read "Albums", ["marketing_budget"],
|
293
|
-
# keys: [[1, 1]], limit: 1
|
294
|
-
# first_album_row = first_album_result.rows.first
|
295
|
-
# first_album_budget = first_album_row.values.first
|
296
|
-
#
|
297
|
-
# # Update the budgets.
|
298
|
-
# second_album_budget -= transfer_amount
|
299
|
-
# first_album_budget += transfer_amount
|
300
|
-
# puts "Setting first album's budget to #{first_album_budget} and the " \
|
301
|
-
# "second album's budget to #{second_album_budget}."
|
302
|
-
#
|
303
|
-
# # Update the rows.
|
304
|
-
# rows = [
|
305
|
-
# {singer_id: 1, album_id: 1, marketing_budget: first_album_budget},
|
306
|
-
# {singer_id: 2, album_id: 2, marketing_budget: second_album_budget}
|
307
|
-
# ]
|
308
|
-
# tx.update "Albums", rows
|
309
|
-
# end
|
310
|
-
# ```
|
311
|
-
#
|
312
|
-
# ## Using read-only transactions
|
313
|
-
#
|
314
|
-
# Suppose you want to execute more than one read at the same timestamp.
|
315
|
-
# Read-only transactions observe a consistent prefix of the transaction
|
316
|
-
# commit history, so your application always gets consistent data. Because
|
317
|
-
# read-only transactions are much faster than locking read-write
|
318
|
-
# transactions, we strongly recommend that you do all of your transaction
|
319
|
-
# reads in read-only transactions if possible.
|
320
|
-
#
|
321
|
-
# Use a {Spanner::Snapshot} object to execute statements in a read-only
|
322
|
-
# transaction. The snapshot object is available via a block provided to
|
323
|
-
# {Spanner::Client#snapshot}:
|
324
|
-
#
|
325
|
-
# ```ruby
|
326
|
-
# require "google/cloud/spanner"
|
327
|
-
#
|
328
|
-
# spanner = Google::Cloud::Spanner.new
|
329
|
-
#
|
330
|
-
# db = spanner.client "my-instance", "my-database"
|
331
|
-
#
|
332
|
-
# db.snapshot do |snp|
|
333
|
-
# results_1 = snp.execute "SELECT * FROM users"
|
334
|
-
# results_1.rows.each do |row|
|
335
|
-
# puts "User #{row[:id]} is #{row[:name]}"
|
336
|
-
# end
|
337
|
-
#
|
338
|
-
# # Perform another read using the `read` method. Even if the data
|
339
|
-
# # is updated in-between the reads, the snapshot ensures that both
|
340
|
-
# # return the same data.
|
341
|
-
# results_2 = db.read "users", [:id, :name]
|
342
|
-
# results_2.rows.each do |row|
|
343
|
-
# puts "User #{row[:id]} is #{row[:name]}"
|
344
|
-
# end
|
345
|
-
# end
|
346
|
-
# ```
|
347
|
-
#
|
348
|
-
# ## Deleting databases
|
349
|
-
#
|
350
|
-
# Use {Spanner::Database#drop} to delete a database:
|
351
|
-
#
|
352
|
-
# ```ruby
|
353
|
-
# require "google/cloud/spanner"
|
354
|
-
#
|
355
|
-
# spanner = Google::Cloud::Spanner.new
|
356
|
-
#
|
357
|
-
# database = spanner.database "my-instance", "my-database"
|
358
|
-
#
|
359
|
-
# database.drop
|
360
|
-
# ```
|
361
|
-
#
|
362
|
-
# ## Deleting instances
|
363
|
-
#
|
364
|
-
# When you delete an instance, all databases within it are automatically
|
365
|
-
# deleted. (If you only delete databases and not your instance, you will
|
366
|
-
# still incur charges for the instance.) Use {Spanner::Instance#delete} to
|
367
|
-
# delete an instance:
|
368
|
-
#
|
369
|
-
# ```ruby
|
370
|
-
# require "google/cloud/spanner"
|
371
|
-
#
|
372
|
-
# spanner = Google::Cloud::Spanner.new
|
373
|
-
#
|
374
|
-
# instance = spanner.instance "my-instance"
|
375
|
-
#
|
376
|
-
# instance.delete
|
377
|
-
# ````
|
34
|
+
# See {file:OVERVIEW.md Spanner Overview}.
|
378
35
|
#
|
379
36
|
module Spanner
|
380
37
|
##
|
@@ -382,8 +39,7 @@ module Google
|
|
382
39
|
# Each call creates a new connection.
|
383
40
|
#
|
384
41
|
# For more information on connecting to Google Cloud see the
|
385
|
-
#
|
386
|
-
# Guide](https://googlecloudplatform.github.io/google-cloud-ruby/#/docs/guides/authentication).
|
42
|
+
# {file:AUTHENTICATION.md Authentication Guide}.
|
387
43
|
#
|
388
44
|
# @param [String] project_id Project identifier for the Spanner service
|
389
45
|
# you are connecting to. If not present, the default project for the
|
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright
|
1
|
+
# Copyright 2018 Google LLC
|
2
2
|
#
|
3
3
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
4
|
# you may not use this file except in compliance with the License.
|
@@ -12,6 +12,7 @@
|
|
12
12
|
# See the License for the specific language governing permissions and
|
13
13
|
# limitations under the License.
|
14
14
|
|
15
|
+
|
15
16
|
require "google/gax"
|
16
17
|
require "pathname"
|
17
18
|
|
@@ -34,17 +35,47 @@ module Google
|
|
34
35
|
#
|
35
36
|
# 1. [Select or create a Cloud Platform project.](https://console.cloud.google.com/project)
|
36
37
|
# 2. [Enable billing for your project.](https://cloud.google.com/billing/docs/how-to/modify-project#enable_billing_for_a_project)
|
37
|
-
# 3. [Enable the Cloud Spanner Database Admin API.](https://console.cloud.google.com/apis/
|
38
|
+
# 3. [Enable the Cloud Spanner Database Admin API.](https://console.cloud.google.com/apis/library/spanner.googleapis.com)
|
38
39
|
# 4. [Setup Authentication.](https://googlecloudplatform.github.io/google-cloud-ruby/#/docs/google-cloud/master/guides/authentication)
|
39
40
|
#
|
41
|
+
# ### Installation
|
42
|
+
# ```
|
43
|
+
# $ gem install google-cloud-spanner
|
44
|
+
# ```
|
45
|
+
#
|
40
46
|
# ### Next Steps
|
41
47
|
# - Read the [Cloud Spanner Database Admin API Product documentation][Product Documentation]
|
42
48
|
# to learn more about the product and see How-to Guides.
|
43
49
|
# - View this [repository's main README](https://github.com/GoogleCloudPlatform/google-cloud-ruby/blob/master/README.md)
|
44
50
|
# to see the full list of Cloud APIs that we cover.
|
45
51
|
#
|
46
|
-
# [Product Documentation]: https://cloud.google.com/spanner
|
52
|
+
# [Product Documentation]: https://cloud.google.com/spanner
|
53
|
+
#
|
54
|
+
# ## Enabling Logging
|
55
|
+
#
|
56
|
+
# To enable logging for this library, set the logger for the underlying [gRPC](https://github.com/grpc/grpc/tree/master/src/ruby) library.
|
57
|
+
# The logger that you set may be a Ruby stdlib [`Logger`](https://ruby-doc.org/stdlib-2.5.0/libdoc/logger/rdoc/Logger.html) as shown below,
|
58
|
+
# or a [`Google::Cloud::Logging::Logger`](https://googlecloudplatform.github.io/google-cloud-ruby/#/docs/google-cloud-logging/latest/google/cloud/logging/logger)
|
59
|
+
# that will write logs to [Stackdriver Logging](https://cloud.google.com/logging/). See [grpc/logconfig.rb](https://github.com/grpc/grpc/blob/master/src/ruby/lib/grpc/logconfig.rb)
|
60
|
+
# and the gRPC [spec_helper.rb](https://github.com/grpc/grpc/blob/master/src/ruby/spec/spec_helper.rb) for additional information.
|
61
|
+
#
|
62
|
+
# Configuring a Ruby stdlib logger:
|
63
|
+
#
|
64
|
+
# ```ruby
|
65
|
+
# require "logger"
|
66
|
+
#
|
67
|
+
# module MyLogger
|
68
|
+
# LOGGER = Logger.new $stderr, level: Logger::WARN
|
69
|
+
# def logger
|
70
|
+
# LOGGER
|
71
|
+
# end
|
72
|
+
# end
|
47
73
|
#
|
74
|
+
# # Define a gRPC module-level logger method before grpc/logconfig.rb loads.
|
75
|
+
# module GRPC
|
76
|
+
# extend MyLogger
|
77
|
+
# end
|
78
|
+
# ```
|
48
79
|
#
|
49
80
|
module Database
|
50
81
|
# rubocop:enable LineLength
|
@@ -92,6 +123,11 @@ module Google
|
|
92
123
|
# or the specified config is missing data points.
|
93
124
|
# @param timeout [Numeric]
|
94
125
|
# The default timeout, in seconds, for calls made through this client.
|
126
|
+
# @param metadata [Hash]
|
127
|
+
# Default metadata to be sent with each request. This can be overridden on a per call basis.
|
128
|
+
# @param exception_transformer [Proc]
|
129
|
+
# An optional proc that intercepts any exceptions raised during an API call to inject
|
130
|
+
# custom error handling.
|
95
131
|
def self.new(*args, version: :v1, **kwargs)
|
96
132
|
unless AVAILABLE_VERSIONS.include?(version.to_s.downcase)
|
97
133
|
raise "The version: #{version} is not available. The available versions " \
|