google-cloud-spanner 1.15.0 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/AUTHENTICATION.md +1 -1
- data/CHANGELOG.md +49 -0
- data/CONTRIBUTING.md +5 -5
- data/TROUBLESHOOTING.md +0 -6
- data/lib/google-cloud-spanner.rb +10 -13
- data/lib/google/cloud/spanner.rb +6 -8
- data/lib/google/cloud/spanner/admin/database/credentials.rb +2 -2
- data/lib/google/cloud/spanner/admin/instance/credentials.rb +2 -2
- data/lib/google/cloud/spanner/backup.rb +315 -0
- data/lib/google/cloud/spanner/backup/job.rb +274 -0
- data/lib/google/cloud/spanner/backup/job/list.rb +177 -0
- data/lib/google/cloud/spanner/backup/list.rb +169 -0
- data/lib/google/cloud/spanner/backup/restore/job.rb +246 -0
- data/lib/google/cloud/spanner/batch_client.rb +2 -2
- data/lib/google/cloud/spanner/batch_snapshot.rb +120 -23
- data/lib/google/cloud/spanner/batch_update.rb +1 -1
- data/lib/google/cloud/spanner/client.rb +189 -30
- data/lib/google/cloud/spanner/commit.rb +14 -14
- data/lib/google/cloud/spanner/convert.rb +7 -7
- data/lib/google/cloud/spanner/credentials.rb +2 -2
- data/lib/google/cloud/spanner/data.rb +2 -2
- data/lib/google/cloud/spanner/database.rb +275 -15
- data/lib/google/cloud/spanner/database/backup_info.rb +105 -0
- data/lib/google/cloud/spanner/database/job.rb +5 -2
- data/lib/google/cloud/spanner/database/job/list.rb +177 -0
- data/lib/google/cloud/spanner/database/list.rb +1 -1
- data/lib/google/cloud/spanner/database/restore_info.rb +63 -0
- data/lib/google/cloud/spanner/fields.rb +8 -8
- data/lib/google/cloud/spanner/instance.rb +401 -8
- data/lib/google/cloud/spanner/instance/config.rb +1 -1
- data/lib/google/cloud/spanner/instance/config/list.rb +1 -1
- data/lib/google/cloud/spanner/instance/job.rb +2 -2
- data/lib/google/cloud/spanner/instance/list.rb +1 -1
- data/lib/google/cloud/spanner/partition.rb +4 -4
- data/lib/google/cloud/spanner/policy.rb +2 -2
- data/lib/google/cloud/spanner/results.rb +9 -6
- data/lib/google/cloud/spanner/service.rb +392 -302
- data/lib/google/cloud/spanner/session.rb +186 -31
- data/lib/google/cloud/spanner/snapshot.rb +60 -6
- data/lib/google/cloud/spanner/transaction.rb +116 -10
- data/lib/google/cloud/spanner/version.rb +1 -1
- metadata +28 -109
- data/lib/google/cloud/spanner/admin/database.rb +0 -149
- data/lib/google/cloud/spanner/admin/database/v1.rb +0 -147
- data/lib/google/cloud/spanner/admin/database/v1/credentials.rb +0 -46
- data/lib/google/cloud/spanner/admin/database/v1/database_admin_client.rb +0 -1513
- data/lib/google/cloud/spanner/admin/database/v1/database_admin_client_config.json +0 -111
- data/lib/google/cloud/spanner/admin/database/v1/doc/google/iam/v1/iam_policy.rb +0 -64
- data/lib/google/cloud/spanner/admin/database/v1/doc/google/iam/v1/options.rb +0 -33
- data/lib/google/cloud/spanner/admin/database/v1/doc/google/iam/v1/policy.rb +0 -151
- data/lib/google/cloud/spanner/admin/database/v1/doc/google/longrunning/operations.rb +0 -51
- data/lib/google/cloud/spanner/admin/database/v1/doc/google/protobuf/any.rb +0 -131
- data/lib/google/cloud/spanner/admin/database/v1/doc/google/protobuf/empty.rb +0 -29
- data/lib/google/cloud/spanner/admin/database/v1/doc/google/protobuf/field_mask.rb +0 -222
- data/lib/google/cloud/spanner/admin/database/v1/doc/google/protobuf/timestamp.rb +0 -113
- data/lib/google/cloud/spanner/admin/database/v1/doc/google/rpc/status.rb +0 -39
- data/lib/google/cloud/spanner/admin/database/v1/doc/google/spanner/admin/database/v1/backup.rb +0 -325
- data/lib/google/cloud/spanner/admin/database/v1/doc/google/spanner/admin/database/v1/spanner_database_admin.rb +0 -368
- data/lib/google/cloud/spanner/admin/database/v1/doc/google/type/expr.rb +0 -45
- data/lib/google/cloud/spanner/admin/instance.rb +0 -164
- data/lib/google/cloud/spanner/admin/instance/v1.rb +0 -162
- data/lib/google/cloud/spanner/admin/instance/v1/credentials.rb +0 -46
- data/lib/google/cloud/spanner/admin/instance/v1/doc/google/iam/v1/iam_policy.rb +0 -64
- data/lib/google/cloud/spanner/admin/instance/v1/doc/google/iam/v1/options.rb +0 -33
- data/lib/google/cloud/spanner/admin/instance/v1/doc/google/iam/v1/policy.rb +0 -151
- data/lib/google/cloud/spanner/admin/instance/v1/doc/google/longrunning/operations.rb +0 -51
- data/lib/google/cloud/spanner/admin/instance/v1/doc/google/protobuf/any.rb +0 -131
- data/lib/google/cloud/spanner/admin/instance/v1/doc/google/protobuf/empty.rb +0 -29
- data/lib/google/cloud/spanner/admin/instance/v1/doc/google/protobuf/field_mask.rb +0 -222
- data/lib/google/cloud/spanner/admin/instance/v1/doc/google/rpc/status.rb +0 -39
- data/lib/google/cloud/spanner/admin/instance/v1/doc/google/spanner/admin/instance/v1/spanner_instance_admin.rb +0 -334
- data/lib/google/cloud/spanner/admin/instance/v1/doc/google/type/expr.rb +0 -45
- data/lib/google/cloud/spanner/admin/instance/v1/instance_admin_client.rb +0 -975
- data/lib/google/cloud/spanner/admin/instance/v1/instance_admin_client_config.json +0 -76
- data/lib/google/cloud/spanner/v1.rb +0 -16
- data/lib/google/cloud/spanner/v1/credentials.rb +0 -42
- data/lib/google/cloud/spanner/v1/doc/google/protobuf/any.rb +0 -131
- data/lib/google/cloud/spanner/v1/doc/google/protobuf/duration.rb +0 -91
- data/lib/google/cloud/spanner/v1/doc/google/protobuf/empty.rb +0 -29
- data/lib/google/cloud/spanner/v1/doc/google/protobuf/struct.rb +0 -74
- data/lib/google/cloud/spanner/v1/doc/google/protobuf/timestamp.rb +0 -113
- data/lib/google/cloud/spanner/v1/doc/google/rpc/status.rb +0 -39
- data/lib/google/cloud/spanner/v1/doc/google/spanner/v1/keys.rb +0 -150
- data/lib/google/cloud/spanner/v1/doc/google/spanner/v1/mutation.rb +0 -95
- data/lib/google/cloud/spanner/v1/doc/google/spanner/v1/query_plan.rb +0 -121
- data/lib/google/cloud/spanner/v1/doc/google/spanner/v1/result_set.rb +0 -190
- data/lib/google/cloud/spanner/v1/doc/google/spanner/v1/spanner.rb +0 -570
- data/lib/google/cloud/spanner/v1/doc/google/spanner/v1/transaction.rb +0 -432
- data/lib/google/cloud/spanner/v1/doc/google/spanner/v1/type.rb +0 -112
- data/lib/google/cloud/spanner/v1/spanner_client.rb +0 -1485
- data/lib/google/cloud/spanner/v1/spanner_client_config.json +0 -121
- data/lib/google/spanner/admin/database/v1/backup_pb.rb +0 -98
- data/lib/google/spanner/admin/database/v1/common_pb.rb +0 -28
- data/lib/google/spanner/admin/database/v1/spanner_database_admin_pb.rb +0 -141
- data/lib/google/spanner/admin/database/v1/spanner_database_admin_services_pb.rb +0 -169
- data/lib/google/spanner/admin/instance/v1/spanner_instance_admin_pb.rb +0 -125
- data/lib/google/spanner/admin/instance/v1/spanner_instance_admin_services_pb.rb +0 -181
- data/lib/google/spanner/v1/keys_pb.rb +0 -34
- data/lib/google/spanner/v1/mutation_pb.rb +0 -39
- data/lib/google/spanner/v1/query_plan_pb.rb +0 -48
- data/lib/google/spanner/v1/result_set_pb.rb +0 -48
- data/lib/google/spanner/v1/spanner_pb.rb +0 -179
- data/lib/google/spanner/v1/spanner_services_pb.rb +0 -179
- data/lib/google/spanner/v1/transaction_pb.rb +0 -56
- data/lib/google/spanner/v1/type_pb.rb +0 -44
|
@@ -142,7 +142,7 @@ module Google
|
|
|
142
142
|
|
|
143
143
|
##
|
|
144
144
|
# @private New Instance::Config::List from a
|
|
145
|
-
# Google::Spanner::Admin::Instance::V1::ListInstanceConfigsResponse
|
|
145
|
+
# `Google::Cloud::Spanner::Admin::Instance::V1::ListInstanceConfigsResponse`
|
|
146
146
|
# object.
|
|
147
147
|
def self.from_grpc grpc, service, max = nil
|
|
148
148
|
configs = List.new(Array(grpc.instance_configs).map do |config|
|
|
@@ -54,7 +54,7 @@ module Google
|
|
|
54
54
|
#
|
|
55
55
|
class Job
|
|
56
56
|
##
|
|
57
|
-
# @private The
|
|
57
|
+
# @private The `Gapic::Operation` gRPC object.
|
|
58
58
|
attr_accessor :grpc
|
|
59
59
|
|
|
60
60
|
##
|
|
@@ -219,7 +219,7 @@ module Google
|
|
|
219
219
|
end
|
|
220
220
|
|
|
221
221
|
##
|
|
222
|
-
# @private New Instance::Job from a
|
|
222
|
+
# @private New Instance::Job from a `Gapic::Operation` object.
|
|
223
223
|
def self.from_grpc grpc, service
|
|
224
224
|
new.tap do |job|
|
|
225
225
|
job.instance_variable_set :@grpc, grpc
|
|
@@ -139,7 +139,7 @@ module Google
|
|
|
139
139
|
|
|
140
140
|
##
|
|
141
141
|
# @private New Instance::List from a
|
|
142
|
-
# Google::Spanner::Admin::Instance::V1::ListInstancesResponse
|
|
142
|
+
# `Google::Cloud::Spanner::Admin::Instance::V1::ListInstancesResponse`
|
|
143
143
|
# object.
|
|
144
144
|
def self.from_grpc grpc, service, max = nil
|
|
145
145
|
instances = List.new(Array(grpc.instances).map do |instance|
|
|
@@ -172,13 +172,13 @@ module Google
|
|
|
172
172
|
new.tap do |p|
|
|
173
173
|
if data[:execute]
|
|
174
174
|
execute_sql_grpc = \
|
|
175
|
-
|
|
175
|
+
V1::ExecuteSqlRequest.decode(
|
|
176
176
|
Base64.decode64(data[:execute])
|
|
177
177
|
)
|
|
178
178
|
p.instance_variable_set :@execute, execute_sql_grpc
|
|
179
179
|
end
|
|
180
180
|
if data[:read]
|
|
181
|
-
read_grpc =
|
|
181
|
+
read_grpc = V1::ReadRequest.decode \
|
|
182
182
|
Base64.decode64(data[:read])
|
|
183
183
|
p.instance_variable_set :@read, read_grpc
|
|
184
184
|
end
|
|
@@ -194,7 +194,7 @@ module Google
|
|
|
194
194
|
end
|
|
195
195
|
|
|
196
196
|
##
|
|
197
|
-
# @private New Partition from a Google::Spanner::V1::ExecuteSqlRequest
|
|
197
|
+
# @private New Partition from a `Google::Cloud::Spanner::V1::ExecuteSqlRequest`
|
|
198
198
|
# object.
|
|
199
199
|
def self.from_execute_sql_grpc grpc
|
|
200
200
|
new.tap do |p|
|
|
@@ -203,7 +203,7 @@ module Google
|
|
|
203
203
|
end
|
|
204
204
|
|
|
205
205
|
##
|
|
206
|
-
# @private New Partition from a Google::Spanner::V1::ReadRequest object.
|
|
206
|
+
# @private New Partition from a `Google::Cloud::Spanner::V1::ReadRequest` object.
|
|
207
207
|
def self.from_read_grpc grpc
|
|
208
208
|
new.tap do |p|
|
|
209
209
|
p.instance_variable_set :@read, grpc
|
|
@@ -159,7 +159,7 @@ module Google
|
|
|
159
159
|
end
|
|
160
160
|
|
|
161
161
|
##
|
|
162
|
-
# @private Convert the Policy to a Google::Iam::V1::Policy object.
|
|
162
|
+
# @private Convert the Policy to a `Google::Iam::V1::Policy` object.
|
|
163
163
|
def to_grpc
|
|
164
164
|
Google::Iam::V1::Policy.new(
|
|
165
165
|
etag: etag,
|
|
@@ -174,7 +174,7 @@ module Google
|
|
|
174
174
|
end
|
|
175
175
|
|
|
176
176
|
##
|
|
177
|
-
# @private New Policy from a Google::Iam::V1::Policy object.
|
|
177
|
+
# @private New Policy from a `Google::Iam::V1::Policy` object.
|
|
178
178
|
def self.from_grpc grpc
|
|
179
179
|
roles = grpc.bindings.each_with_object({}) do |binding, memo|
|
|
180
180
|
memo[binding.role] = binding.members.to_a
|
|
@@ -243,11 +243,11 @@ module Google
|
|
|
243
243
|
def self.execute_query service, session_path, sql, params: nil,
|
|
244
244
|
types: nil, transaction: nil,
|
|
245
245
|
partition_token: nil, seqno: nil,
|
|
246
|
-
query_options: nil
|
|
246
|
+
query_options: nil, call_options: nil
|
|
247
247
|
execute_query_options = {
|
|
248
248
|
transaction: transaction, params: params, types: types,
|
|
249
249
|
partition_token: partition_token, seqno: seqno,
|
|
250
|
-
query_options: query_options
|
|
250
|
+
query_options: query_options, call_options: call_options
|
|
251
251
|
}
|
|
252
252
|
enum = service.execute_streaming_sql session_path, sql,
|
|
253
253
|
execute_query_options
|
|
@@ -262,10 +262,13 @@ module Google
|
|
|
262
262
|
# @private
|
|
263
263
|
def self.read service, session_path, table, columns, keys: nil,
|
|
264
264
|
index: nil, limit: nil, transaction: nil,
|
|
265
|
-
partition_token: nil
|
|
266
|
-
read_options = {
|
|
267
|
-
|
|
268
|
-
|
|
265
|
+
partition_token: nil, call_options: nil
|
|
266
|
+
read_options = {
|
|
267
|
+
keys: keys, index: index, limit: limit,
|
|
268
|
+
transaction: transaction,
|
|
269
|
+
partition_token: partition_token,
|
|
270
|
+
call_options: call_options
|
|
271
|
+
}
|
|
269
272
|
enum = service.streaming_read_table \
|
|
270
273
|
session_path, table, columns, read_options
|
|
271
274
|
from_enum(enum, service).tap do |results|
|
|
@@ -20,7 +20,6 @@ require "google/cloud/spanner/v1"
|
|
|
20
20
|
require "google/cloud/spanner/admin/instance/v1"
|
|
21
21
|
require "google/cloud/spanner/admin/database/v1"
|
|
22
22
|
require "google/cloud/spanner/convert"
|
|
23
|
-
require "uri"
|
|
24
23
|
|
|
25
24
|
module Google
|
|
26
25
|
module Cloud
|
|
@@ -29,18 +28,17 @@ module Google
|
|
|
29
28
|
# @private Represents the gRPC Spanner service, including all the API
|
|
30
29
|
# methods.
|
|
31
30
|
class Service
|
|
32
|
-
attr_accessor :project, :credentials, :timeout, :
|
|
33
|
-
:
|
|
31
|
+
attr_accessor :project, :credentials, :timeout, :host, :lib_name,
|
|
32
|
+
:lib_version
|
|
34
33
|
|
|
35
34
|
##
|
|
36
35
|
# Creates a new Service instance.
|
|
37
|
-
def initialize project, credentials,
|
|
38
|
-
|
|
36
|
+
def initialize project, credentials,
|
|
37
|
+
host: nil, timeout: nil, lib_name: nil, lib_version: nil
|
|
39
38
|
@project = project
|
|
40
39
|
@credentials = credentials
|
|
41
|
-
@host = host
|
|
40
|
+
@host = host
|
|
42
41
|
@timeout = timeout
|
|
43
|
-
@client_config = client_config || {}
|
|
44
42
|
@lib_name = lib_name
|
|
45
43
|
@lib_version = lib_version
|
|
46
44
|
end
|
|
@@ -64,45 +62,42 @@ module Google
|
|
|
64
62
|
def service
|
|
65
63
|
return mocked_service if mocked_service
|
|
66
64
|
@service ||= \
|
|
67
|
-
V1::
|
|
68
|
-
credentials
|
|
69
|
-
timeout
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
)
|
|
65
|
+
V1::Spanner::Client.new do |config|
|
|
66
|
+
config.credentials = channel
|
|
67
|
+
config.timeout = timeout if timeout
|
|
68
|
+
config.endpoint = host if host
|
|
69
|
+
config.lib_name = lib_name_with_prefix
|
|
70
|
+
config.lib_version = Google::Cloud::Spanner::VERSION
|
|
71
|
+
config.metadata = { "google-cloud-resource-prefix" => "projects/#{@project}" }
|
|
72
|
+
end
|
|
76
73
|
end
|
|
77
74
|
attr_accessor :mocked_service
|
|
78
75
|
|
|
79
76
|
def instances
|
|
80
77
|
return mocked_instances if mocked_instances
|
|
81
78
|
@instances ||= \
|
|
82
|
-
Admin::Instance::V1::
|
|
83
|
-
credentials
|
|
84
|
-
timeout
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
)
|
|
79
|
+
Admin::Instance::V1::InstanceAdmin::Client.new do |config|
|
|
80
|
+
config.credentials = channel
|
|
81
|
+
config.timeout = timeout if timeout
|
|
82
|
+
config.endpoint = host if host
|
|
83
|
+
config.lib_name = lib_name_with_prefix
|
|
84
|
+
config.lib_version = Google::Cloud::Spanner::VERSION
|
|
85
|
+
config.metadata = { "google-cloud-resource-prefix" => "projects/#{@project}" }
|
|
86
|
+
end
|
|
91
87
|
end
|
|
92
88
|
attr_accessor :mocked_instances
|
|
93
89
|
|
|
94
90
|
def databases
|
|
95
91
|
return mocked_databases if mocked_databases
|
|
96
92
|
@databases ||= \
|
|
97
|
-
Admin::Database::V1::
|
|
98
|
-
credentials
|
|
99
|
-
timeout
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
)
|
|
93
|
+
Admin::Database::V1::DatabaseAdmin::Client.new do |config|
|
|
94
|
+
config.credentials = channel
|
|
95
|
+
config.timeout = timeout if timeout
|
|
96
|
+
config.endpoint = host if host
|
|
97
|
+
config.lib_name = lib_name_with_prefix
|
|
98
|
+
config.lib_version = Google::Cloud::Spanner::VERSION
|
|
99
|
+
config.metadata = { "google-cloud-resource-prefix" => "projects/#{@project}" }
|
|
100
|
+
end
|
|
106
101
|
end
|
|
107
102
|
attr_accessor :mocked_databases
|
|
108
103
|
|
|
@@ -110,225 +105,239 @@ module Google
|
|
|
110
105
|
credentials == :this_channel_is_insecure
|
|
111
106
|
end
|
|
112
107
|
|
|
113
|
-
def list_instances token: nil, max: nil
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
paged_enum.page.response
|
|
123
|
-
end
|
|
108
|
+
def list_instances token: nil, max: nil, call_options: nil
|
|
109
|
+
opts = default_options call_options: call_options
|
|
110
|
+
request = {
|
|
111
|
+
parent: project_path,
|
|
112
|
+
page_size: max,
|
|
113
|
+
page_token: token
|
|
114
|
+
}
|
|
115
|
+
paged_enum = instances.list_instances request, opts
|
|
116
|
+
paged_enum.response
|
|
124
117
|
end
|
|
125
118
|
|
|
126
|
-
def get_instance name
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
119
|
+
def get_instance name, call_options: nil
|
|
120
|
+
opts = default_options call_options: call_options
|
|
121
|
+
request = { name: instance_path(name) }
|
|
122
|
+
instances.get_instance request, opts
|
|
130
123
|
end
|
|
131
124
|
|
|
132
125
|
def create_instance instance_id, name: nil, config: nil, nodes: nil,
|
|
133
|
-
labels: nil
|
|
126
|
+
labels: nil, call_options: nil
|
|
127
|
+
opts = default_options call_options: call_options
|
|
134
128
|
labels = Hash[labels.map { |k, v| [String(k), String(v)] }] if labels
|
|
135
129
|
|
|
136
|
-
create_obj =
|
|
130
|
+
create_obj = Admin::Instance::V1::Instance.new({
|
|
137
131
|
display_name: name, config: instance_config_path(config),
|
|
138
132
|
node_count: nodes, labels: labels
|
|
139
133
|
}.delete_if { |_, v| v.nil? })
|
|
140
134
|
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
135
|
+
request = {
|
|
136
|
+
parent: project_path,
|
|
137
|
+
instance_id: instance_id,
|
|
138
|
+
instance: create_obj
|
|
139
|
+
}
|
|
140
|
+
instances.create_instance request, opts
|
|
144
141
|
end
|
|
145
142
|
|
|
146
|
-
def update_instance
|
|
143
|
+
def update_instance instance, call_options: nil
|
|
144
|
+
opts = default_options call_options: call_options
|
|
147
145
|
mask = Google::Protobuf::FieldMask.new(
|
|
148
146
|
paths: %w[display_name node_count labels]
|
|
149
147
|
)
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
instances.update_instance instance_obj, mask
|
|
153
|
-
end
|
|
148
|
+
request = { instance: instance, field_mask: mask }
|
|
149
|
+
instances.update_instance request, opts
|
|
154
150
|
end
|
|
155
151
|
|
|
156
|
-
def delete_instance name
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
152
|
+
def delete_instance name, call_options: nil
|
|
153
|
+
opts = default_options call_options: call_options
|
|
154
|
+
request = { name: instance_path(name) }
|
|
155
|
+
instances.delete_instance request, opts
|
|
160
156
|
end
|
|
161
157
|
|
|
162
|
-
def get_instance_policy name
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
158
|
+
def get_instance_policy name, call_options: nil
|
|
159
|
+
opts = default_options call_options: call_options
|
|
160
|
+
request = { resource: instance_path(name) }
|
|
161
|
+
instances.get_iam_policy request, opts
|
|
166
162
|
end
|
|
167
163
|
|
|
168
|
-
def set_instance_policy name, new_policy
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
164
|
+
def set_instance_policy name, new_policy, call_options: nil
|
|
165
|
+
opts = default_options call_options: call_options
|
|
166
|
+
request = {
|
|
167
|
+
resource: instance_path(name),
|
|
168
|
+
policy: new_policy
|
|
169
|
+
}
|
|
170
|
+
instances.set_iam_policy request, opts
|
|
172
171
|
end
|
|
173
172
|
|
|
174
|
-
def test_instance_permissions name, permissions
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
173
|
+
def test_instance_permissions name, permissions, call_options: nil
|
|
174
|
+
opts = default_options call_options: call_options
|
|
175
|
+
request = {
|
|
176
|
+
resource: instance_path(name),
|
|
177
|
+
permissions: permissions
|
|
178
|
+
}
|
|
179
|
+
instances.test_iam_permissions request, opts
|
|
178
180
|
end
|
|
179
181
|
|
|
180
|
-
def list_instance_configs token: nil, max: nil
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
paged_enum = instances.list_instance_configs project_path,
|
|
186
|
-
page_size: max,
|
|
187
|
-
options: call_options
|
|
188
|
-
|
|
189
|
-
paged_enum.page.response
|
|
190
|
-
end
|
|
182
|
+
def list_instance_configs token: nil, max: nil, call_options: nil
|
|
183
|
+
opts = default_options call_options: call_options
|
|
184
|
+
request = { parent: project_path, page_size: max, page_token: token }
|
|
185
|
+
paged_enum = instances.list_instance_configs request, opts
|
|
186
|
+
paged_enum.response
|
|
191
187
|
end
|
|
192
188
|
|
|
193
|
-
def get_instance_config name
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
189
|
+
def get_instance_config name, call_options: nil
|
|
190
|
+
opts = default_options call_options: call_options
|
|
191
|
+
request = { name: instance_config_path(name) }
|
|
192
|
+
instances.get_instance_config request, opts
|
|
197
193
|
end
|
|
198
194
|
|
|
199
|
-
def list_databases instance_id, token: nil, max: nil
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
paged_enum.page.response
|
|
209
|
-
end
|
|
195
|
+
def list_databases instance_id, token: nil, max: nil, call_options: nil
|
|
196
|
+
opts = default_options call_options: call_options
|
|
197
|
+
request = {
|
|
198
|
+
parent: instance_path(instance_id),
|
|
199
|
+
page_size: max,
|
|
200
|
+
page_token: token
|
|
201
|
+
}
|
|
202
|
+
paged_enum = databases.list_databases request, opts
|
|
203
|
+
paged_enum.response
|
|
210
204
|
end
|
|
211
205
|
|
|
212
|
-
def get_database instance_id, database_id
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
206
|
+
def get_database instance_id, database_id, call_options: nil
|
|
207
|
+
opts = default_options call_options: call_options
|
|
208
|
+
request = { name: database_path(instance_id, database_id) }
|
|
209
|
+
databases.get_database request, opts
|
|
216
210
|
end
|
|
217
211
|
|
|
218
|
-
def create_database instance_id, database_id, statements: []
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
212
|
+
def create_database instance_id, database_id, statements: [],
|
|
213
|
+
call_options: nil
|
|
214
|
+
opts = default_options call_options: call_options
|
|
215
|
+
request = {
|
|
216
|
+
parent: instance_path(instance_id),
|
|
217
|
+
create_statement: "CREATE DATABASE `#{database_id}`",
|
|
218
|
+
extra_statements: Array(statements)
|
|
219
|
+
}
|
|
220
|
+
databases.create_database request, opts
|
|
225
221
|
end
|
|
226
222
|
|
|
227
|
-
def drop_database instance_id, database_id
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
223
|
+
def drop_database instance_id, database_id, call_options: nil
|
|
224
|
+
opts = default_options call_options: call_options
|
|
225
|
+
request = { database: database_path(instance_id, database_id) }
|
|
226
|
+
databases.drop_database request, opts
|
|
231
227
|
end
|
|
232
228
|
|
|
233
|
-
def get_database_ddl instance_id, database_id
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
229
|
+
def get_database_ddl instance_id, database_id, call_options: nil
|
|
230
|
+
opts = default_options call_options: call_options
|
|
231
|
+
request = { database: database_path(instance_id, database_id) }
|
|
232
|
+
databases.get_database_ddl request, opts
|
|
237
233
|
end
|
|
238
234
|
|
|
239
235
|
def update_database_ddl instance_id, database_id, statements: [],
|
|
240
|
-
operation_id: nil
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
end
|
|
275
|
-
|
|
276
|
-
def
|
|
277
|
-
opts =
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
236
|
+
operation_id: nil, call_options: nil
|
|
237
|
+
opts = default_options call_options: call_options
|
|
238
|
+
request = {
|
|
239
|
+
database: database_path(instance_id, database_id),
|
|
240
|
+
statements: Array(statements),
|
|
241
|
+
operation_id: operation_id
|
|
242
|
+
}
|
|
243
|
+
databases.update_database_ddl request, opts
|
|
244
|
+
end
|
|
245
|
+
|
|
246
|
+
def get_database_policy instance_id, database_id, call_options: nil
|
|
247
|
+
opts = default_options call_options: call_options
|
|
248
|
+
request = { resource: database_path(instance_id, database_id) }
|
|
249
|
+
databases.get_iam_policy request, opts
|
|
250
|
+
end
|
|
251
|
+
|
|
252
|
+
def set_database_policy instance_id, database_id, new_policy,
|
|
253
|
+
call_options: nil
|
|
254
|
+
opts = default_options call_options: call_options
|
|
255
|
+
request = {
|
|
256
|
+
resource: database_path(instance_id, database_id),
|
|
257
|
+
policy: new_policy
|
|
258
|
+
}
|
|
259
|
+
databases.set_iam_policy request, opts
|
|
260
|
+
end
|
|
261
|
+
|
|
262
|
+
def test_database_permissions instance_id, database_id, permissions,
|
|
263
|
+
call_options: nil
|
|
264
|
+
opts = default_options call_options: call_options
|
|
265
|
+
request = {
|
|
266
|
+
resource: database_path(instance_id, database_id),
|
|
267
|
+
permissions: permissions
|
|
268
|
+
}
|
|
269
|
+
databases.test_iam_permissions request, opts
|
|
270
|
+
end
|
|
271
|
+
|
|
272
|
+
def get_session session_name, call_options: nil
|
|
273
|
+
opts = default_options session_name: session_name,
|
|
274
|
+
call_options: call_options
|
|
275
|
+
service.get_session({ name: session_name }, opts)
|
|
276
|
+
end
|
|
277
|
+
|
|
278
|
+
def create_session database_name, labels: nil,
|
|
279
|
+
call_options: nil
|
|
280
|
+
opts = default_options session_name: database_name,
|
|
281
|
+
call_options: call_options
|
|
282
|
+
session = V1::Session.new labels: labels if labels
|
|
283
|
+
service.create_session(
|
|
284
|
+
{ database: database_name, session: session }, opts
|
|
285
|
+
)
|
|
283
286
|
end
|
|
284
287
|
|
|
285
|
-
def batch_create_sessions database_name, session_count, labels: nil
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
288
|
+
def batch_create_sessions database_name, session_count, labels: nil,
|
|
289
|
+
call_options: nil
|
|
290
|
+
opts = default_options session_name: database_name,
|
|
291
|
+
call_options: call_options
|
|
292
|
+
session = V1::Session.new labels: labels if labels
|
|
293
|
+
# The response may have fewer sessions than requested in the RPC.
|
|
294
|
+
request = {
|
|
295
|
+
database: database_name,
|
|
296
|
+
session_count: session_count,
|
|
297
|
+
session_template: session
|
|
298
|
+
}
|
|
299
|
+
service.batch_create_sessions request, opts
|
|
295
300
|
end
|
|
296
301
|
|
|
297
|
-
def delete_session session_name
|
|
298
|
-
opts =
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
end
|
|
302
|
+
def delete_session session_name, call_options: nil
|
|
303
|
+
opts = default_options session_name: session_name,
|
|
304
|
+
call_options: call_options
|
|
305
|
+
service.delete_session({ name: session_name }, opts)
|
|
302
306
|
end
|
|
303
307
|
|
|
304
308
|
def execute_streaming_sql session_name, sql, transaction: nil,
|
|
305
309
|
params: nil, types: nil, resume_token: nil,
|
|
306
310
|
partition_token: nil, seqno: nil,
|
|
307
|
-
query_options: nil
|
|
308
|
-
opts =
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
311
|
+
query_options: nil, call_options: nil
|
|
312
|
+
opts = default_options session_name: session_name,
|
|
313
|
+
call_options: call_options
|
|
314
|
+
request = {
|
|
315
|
+
session: session_name,
|
|
316
|
+
sql: sql,
|
|
317
|
+
transaction: transaction,
|
|
318
|
+
params: params,
|
|
319
|
+
param_types: types,
|
|
320
|
+
resume_token: resume_token,
|
|
321
|
+
partition_token: partition_token,
|
|
322
|
+
seqno: seqno,
|
|
323
|
+
query_options: query_options
|
|
324
|
+
}
|
|
325
|
+
service.execute_streaming_sql request, opts
|
|
326
|
+
end
|
|
327
|
+
|
|
328
|
+
def execute_batch_dml session_name, transaction, statements, seqno,
|
|
329
|
+
call_options: nil
|
|
330
|
+
opts = default_options session_name: session_name,
|
|
331
|
+
call_options: call_options
|
|
324
332
|
statements = statements.map(&:to_grpc)
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
333
|
+
request = {
|
|
334
|
+
session: session_name,
|
|
335
|
+
transaction: transaction,
|
|
336
|
+
statements: statements,
|
|
337
|
+
seqno: seqno
|
|
338
|
+
}
|
|
339
|
+
results = service.execute_batch_dml request, opts
|
|
340
|
+
|
|
332
341
|
if results.status.code.zero?
|
|
333
342
|
results.result_sets.map { |rs| rs.stats.row_count_exact }
|
|
334
343
|
else
|
|
@@ -342,87 +351,89 @@ module Google
|
|
|
342
351
|
|
|
343
352
|
def streaming_read_table session_name, table_name, columns, keys: nil,
|
|
344
353
|
index: nil, transaction: nil, limit: nil,
|
|
345
|
-
resume_token: nil, partition_token: nil
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
+
resume_token: nil, partition_token: nil,
|
|
355
|
+
call_options: nil
|
|
356
|
+
opts = default_options session_name: session_name,
|
|
357
|
+
call_options: call_options
|
|
358
|
+
request = {
|
|
359
|
+
session: session_name, table: table_name, columns: columns,
|
|
360
|
+
key_set: keys, transaction: transaction, index: index,
|
|
361
|
+
limit: limit, resume_token: resume_token,
|
|
362
|
+
partition_token: partition_token
|
|
363
|
+
}
|
|
364
|
+
service.streaming_read request, opts
|
|
354
365
|
end
|
|
355
366
|
|
|
356
367
|
def partition_read session_name, table_name, columns, transaction,
|
|
357
368
|
keys: nil, index: nil, partition_size_bytes: nil,
|
|
358
|
-
max_partitions: nil
|
|
369
|
+
max_partitions: nil, call_options: nil
|
|
359
370
|
partition_opts = partition_options partition_size_bytes,
|
|
360
371
|
max_partitions
|
|
361
372
|
|
|
362
|
-
opts =
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
373
|
+
opts = default_options session_name: session_name,
|
|
374
|
+
call_options: call_options
|
|
375
|
+
request = {
|
|
376
|
+
session: session_name, table: table_name, key_set: keys,
|
|
377
|
+
transaction: transaction, index: index, columns: columns,
|
|
378
|
+
partition_options: partition_opts
|
|
379
|
+
}
|
|
380
|
+
service.partition_read request, opts
|
|
370
381
|
end
|
|
371
382
|
|
|
372
383
|
def partition_query session_name, sql, transaction, params: nil,
|
|
373
384
|
types: nil, partition_size_bytes: nil,
|
|
374
|
-
max_partitions: nil
|
|
385
|
+
max_partitions: nil, call_options: nil
|
|
375
386
|
partition_opts = partition_options partition_size_bytes,
|
|
376
387
|
max_partitions
|
|
377
388
|
|
|
378
|
-
opts =
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
end
|
|
389
|
+
opts = default_options session_name: session_name,
|
|
390
|
+
call_options: call_options
|
|
391
|
+
request = {
|
|
392
|
+
session: session_name, sql: sql, transaction: transaction,
|
|
393
|
+
params: params, param_types: types,
|
|
394
|
+
partition_options: partition_opts
|
|
395
|
+
}
|
|
396
|
+
service.partition_query request, opts
|
|
387
397
|
end
|
|
388
398
|
|
|
389
|
-
def commit session_name, mutations = [], transaction_id: nil
|
|
399
|
+
def commit session_name, mutations = [], transaction_id: nil,
|
|
400
|
+
call_options: nil
|
|
390
401
|
tx_opts = nil
|
|
391
402
|
if transaction_id.nil?
|
|
392
|
-
tx_opts =
|
|
393
|
-
read_write:
|
|
403
|
+
tx_opts = V1::TransactionOptions.new(
|
|
404
|
+
read_write: V1::TransactionOptions::ReadWrite.new
|
|
394
405
|
)
|
|
395
406
|
end
|
|
396
|
-
opts =
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
407
|
+
opts = default_options session_name: session_name,
|
|
408
|
+
call_options: call_options
|
|
409
|
+
request = {
|
|
410
|
+
session: session_name, transaction_id: transaction_id,
|
|
411
|
+
single_use_transaction: tx_opts, mutations: mutations
|
|
412
|
+
}
|
|
413
|
+
service.commit request, opts
|
|
403
414
|
end
|
|
404
415
|
|
|
405
|
-
def rollback session_name, transaction_id
|
|
406
|
-
opts =
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
416
|
+
def rollback session_name, transaction_id, call_options: nil
|
|
417
|
+
opts = default_options session_name: session_name,
|
|
418
|
+
call_options: call_options
|
|
419
|
+
request = { session: session_name, transaction_id: transaction_id }
|
|
420
|
+
service.rollback request, opts
|
|
410
421
|
end
|
|
411
422
|
|
|
412
|
-
def begin_transaction session_name
|
|
413
|
-
tx_opts =
|
|
414
|
-
read_write:
|
|
423
|
+
def begin_transaction session_name, call_options: nil
|
|
424
|
+
tx_opts = V1::TransactionOptions.new(
|
|
425
|
+
read_write: V1::TransactionOptions::ReadWrite.new
|
|
415
426
|
)
|
|
416
|
-
opts =
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
427
|
+
opts = default_options session_name: session_name,
|
|
428
|
+
call_options: call_options
|
|
429
|
+
request = { session: session_name, options: tx_opts }
|
|
430
|
+
service.begin_transaction request, opts
|
|
420
431
|
end
|
|
421
432
|
|
|
422
433
|
def create_snapshot session_name, strong: nil, timestamp: nil,
|
|
423
|
-
staleness: nil
|
|
424
|
-
tx_opts =
|
|
425
|
-
read_only:
|
|
434
|
+
staleness: nil, call_options: nil
|
|
435
|
+
tx_opts = V1::TransactionOptions.new(
|
|
436
|
+
read_only: V1::TransactionOptions::ReadOnly.new(
|
|
426
437
|
{
|
|
427
438
|
strong: strong,
|
|
428
439
|
read_timestamp: Convert.time_to_timestamp(timestamp),
|
|
@@ -431,21 +442,107 @@ module Google
|
|
|
431
442
|
}.delete_if { |_, v| v.nil? }
|
|
432
443
|
)
|
|
433
444
|
)
|
|
434
|
-
opts =
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
445
|
+
opts = default_options session_name: session_name,
|
|
446
|
+
call_options: call_options
|
|
447
|
+
request = { session: session_name, options: tx_opts }
|
|
448
|
+
service.begin_transaction request, opts
|
|
438
449
|
end
|
|
439
450
|
|
|
440
|
-
def create_pdml session_name
|
|
441
|
-
tx_opts =
|
|
442
|
-
partitioned_dml:
|
|
443
|
-
Google::Spanner::V1::TransactionOptions::PartitionedDml.new
|
|
451
|
+
def create_pdml session_name, call_options: nil
|
|
452
|
+
tx_opts = V1::TransactionOptions.new(
|
|
453
|
+
partitioned_dml: V1::TransactionOptions::PartitionedDml.new
|
|
444
454
|
)
|
|
445
|
-
opts =
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
455
|
+
opts = default_options session_name: session_name,
|
|
456
|
+
call_options: call_options
|
|
457
|
+
request = { session: session_name, options: tx_opts }
|
|
458
|
+
service.begin_transaction request, opts
|
|
459
|
+
end
|
|
460
|
+
|
|
461
|
+
def create_backup instance_id, database_id, backup_id, expire_time,
|
|
462
|
+
call_options: nil
|
|
463
|
+
opts = default_options call_options: call_options
|
|
464
|
+
backup = {
|
|
465
|
+
database: database_path(instance_id, database_id),
|
|
466
|
+
expire_time: expire_time
|
|
467
|
+
}
|
|
468
|
+
request = {
|
|
469
|
+
parent: instance_path(instance_id),
|
|
470
|
+
backup_id: backup_id,
|
|
471
|
+
backup: backup
|
|
472
|
+
}
|
|
473
|
+
databases.create_backup request, opts
|
|
474
|
+
end
|
|
475
|
+
|
|
476
|
+
def get_backup instance_id, backup_id, call_options: nil
|
|
477
|
+
opts = default_options call_options: call_options
|
|
478
|
+
request = { name: backup_path(instance_id, backup_id) }
|
|
479
|
+
databases.get_backup request, opts
|
|
480
|
+
end
|
|
481
|
+
|
|
482
|
+
def update_backup backup, update_mask, call_options: nil
|
|
483
|
+
opts = default_options call_options: call_options
|
|
484
|
+
request = { backup: backup, update_mask: update_mask }
|
|
485
|
+
databases.update_backup request, opts
|
|
486
|
+
end
|
|
487
|
+
|
|
488
|
+
def delete_backup instance_id, backup_id, call_options: nil
|
|
489
|
+
opts = default_options call_options: call_options
|
|
490
|
+
request = { name: backup_path(instance_id, backup_id) }
|
|
491
|
+
databases.delete_backup request, opts
|
|
492
|
+
end
|
|
493
|
+
|
|
494
|
+
def list_backups instance_id,
|
|
495
|
+
filter: nil, page_size: nil, page_token: nil,
|
|
496
|
+
call_options: nil
|
|
497
|
+
opts = default_options call_options: call_options
|
|
498
|
+
request = {
|
|
499
|
+
parent: instance_path(instance_id),
|
|
500
|
+
filter: filter,
|
|
501
|
+
page_size: page_size,
|
|
502
|
+
page_token: page_token
|
|
503
|
+
}
|
|
504
|
+
databases.list_backups request, opts
|
|
505
|
+
end
|
|
506
|
+
|
|
507
|
+
def list_database_operations instance_id,
|
|
508
|
+
filter: nil,
|
|
509
|
+
page_size: nil,
|
|
510
|
+
page_token: nil,
|
|
511
|
+
call_options: nil
|
|
512
|
+
opts = default_options call_options: call_options
|
|
513
|
+
request = {
|
|
514
|
+
parent: instance_path(instance_id),
|
|
515
|
+
filter: filter,
|
|
516
|
+
page_size: page_size,
|
|
517
|
+
page_token: page_token
|
|
518
|
+
}
|
|
519
|
+
databases.list_database_operations request, opts
|
|
520
|
+
end
|
|
521
|
+
|
|
522
|
+
def list_backup_operations instance_id,
|
|
523
|
+
filter: nil, page_size: nil,
|
|
524
|
+
page_token: nil,
|
|
525
|
+
call_options: nil
|
|
526
|
+
opts = default_options call_options: call_options
|
|
527
|
+
request = {
|
|
528
|
+
parent: instance_path(instance_id),
|
|
529
|
+
filter: filter,
|
|
530
|
+
page_size: page_size,
|
|
531
|
+
page_token: page_token
|
|
532
|
+
}
|
|
533
|
+
databases.list_backup_operations request, opts
|
|
534
|
+
end
|
|
535
|
+
|
|
536
|
+
def restore_database backup_instance_id, backup_id,
|
|
537
|
+
database_instance_id, database_id,
|
|
538
|
+
call_options: nil
|
|
539
|
+
opts = default_options call_options: call_options
|
|
540
|
+
request = {
|
|
541
|
+
parent: instance_path(database_instance_id),
|
|
542
|
+
database_id: database_id,
|
|
543
|
+
backup: backup_path(backup_instance_id, backup_id)
|
|
544
|
+
}
|
|
545
|
+
databases.restore_database request, opts
|
|
449
546
|
end
|
|
450
547
|
|
|
451
548
|
def inspect
|
|
@@ -454,16 +551,6 @@ module Google
|
|
|
454
551
|
|
|
455
552
|
protected
|
|
456
553
|
|
|
457
|
-
def service_address
|
|
458
|
-
return nil if host.nil?
|
|
459
|
-
URI.parse("//#{host}").host
|
|
460
|
-
end
|
|
461
|
-
|
|
462
|
-
def service_port
|
|
463
|
-
return nil if host.nil?
|
|
464
|
-
URI.parse("//#{host}").port
|
|
465
|
-
end
|
|
466
|
-
|
|
467
554
|
def lib_name_with_prefix
|
|
468
555
|
return "gccl" if [nil, "gccl"].include? lib_name
|
|
469
556
|
|
|
@@ -472,15 +559,22 @@ module Google
|
|
|
472
559
|
value << " gccl"
|
|
473
560
|
end
|
|
474
561
|
|
|
475
|
-
def
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
562
|
+
def default_options session_name: nil, call_options: nil
|
|
563
|
+
opts = {}
|
|
564
|
+
if session_name
|
|
565
|
+
default_prefix = session_name.split("/sessions/").first
|
|
566
|
+
opts[:metadata] = { "google-cloud-resource-prefix" => default_prefix }
|
|
567
|
+
end
|
|
568
|
+
if call_options
|
|
569
|
+
opts[:timeout] = call_options[:timeout] if call_options[:timeout]
|
|
570
|
+
opts[:retry_policy] = call_options[:retry_policy] if call_options[:retry_policy]
|
|
571
|
+
end
|
|
572
|
+
return opts unless opts.empty?
|
|
479
573
|
end
|
|
480
574
|
|
|
481
575
|
def partition_options partition_size_bytes, max_partitions
|
|
482
576
|
return nil unless partition_size_bytes || max_partitions
|
|
483
|
-
partition_opts =
|
|
577
|
+
partition_opts = V1::PartitionOptions.new
|
|
484
578
|
if partition_size_bytes
|
|
485
579
|
partition_opts.partition_size_bytes = partition_size_bytes
|
|
486
580
|
end
|
|
@@ -489,42 +583,38 @@ module Google
|
|
|
489
583
|
end
|
|
490
584
|
|
|
491
585
|
def project_path
|
|
492
|
-
Admin::Instance::V1::
|
|
586
|
+
Admin::Instance::V1::InstanceAdmin::Paths.project_path \
|
|
587
|
+
project: project
|
|
493
588
|
end
|
|
494
589
|
|
|
495
590
|
def instance_path name
|
|
496
591
|
return name if name.to_s.include? "/"
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
592
|
+
|
|
593
|
+
Admin::Instance::V1::InstanceAdmin::Paths.instance_path \
|
|
594
|
+
project: project, instance: name
|
|
500
595
|
end
|
|
501
596
|
|
|
502
597
|
def instance_config_path name
|
|
503
598
|
return name if name.to_s.include? "/"
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
599
|
+
|
|
600
|
+
Admin::Instance::V1::InstanceAdmin::Paths.instance_config_path \
|
|
601
|
+
project: project, instance_config: name
|
|
507
602
|
end
|
|
508
603
|
|
|
509
604
|
def database_path instance_id, database_id
|
|
510
|
-
Admin::Database::V1::
|
|
511
|
-
project, instance_id, database_id
|
|
512
|
-
)
|
|
605
|
+
Admin::Database::V1::DatabaseAdmin::Paths.database_path \
|
|
606
|
+
project: project, instance: instance_id, database: database_id
|
|
513
607
|
end
|
|
514
608
|
|
|
515
609
|
def session_path instance_id, database_id, session_id
|
|
516
|
-
V1::
|
|
517
|
-
project, instance_id, database_id,
|
|
518
|
-
|
|
610
|
+
V1::Spanner::Paths.session_path \
|
|
611
|
+
project: project, instance: instance_id, database: database_id,
|
|
612
|
+
session: session_id
|
|
519
613
|
end
|
|
520
614
|
|
|
521
|
-
def
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
# GaxError wraps BadStatus, but exposes it as #cause
|
|
525
|
-
raise Google::Cloud::Error.from_error(e.cause)
|
|
526
|
-
rescue GRPC::BadStatus => e
|
|
527
|
-
raise Google::Cloud::Error.from_error(e)
|
|
615
|
+
def backup_path instance_id, backup_id
|
|
616
|
+
Admin::Database::V1::DatabaseAdmin::Paths.backup_path \
|
|
617
|
+
project: project, instance: instance_id, backup: backup_id
|
|
528
618
|
end
|
|
529
619
|
end
|
|
530
620
|
end
|