google-cloud-spanner 2.7.0 → 2.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +11 -0
- data/lib/google/cloud/spanner/instance.rb +61 -1
- data/lib/google/cloud/spanner/project.rb +29 -3
- data/lib/google/cloud/spanner/service.rb +14 -7
- data/lib/google/cloud/spanner/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e8347879380e3278cec1dee95179755b0f1ff4ffecea9fae6b04861bd43976d1
|
4
|
+
data.tar.gz: b6c66cb0637a396bfee1e590b6316826f24a5dc45739c57de19c14c0304bc501
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5a2caf305e7484bd7c17d89973ee3eb536a11b202fa7b85443f33b60ebafc65fb67a57106ca75fda2d448c45614479c44745344af17267f6577b37a5389c2d02
|
7
|
+
data.tar.gz: 3be51dc4c55d948f57c19e2be190cbc27b259793d63b77d366ae9bc8beb7e64c67135127e130b3837305576a41eb5ae370e810ec58ccbb46f627e0816c0359f8
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,16 @@
|
|
1
1
|
# Release History
|
2
2
|
|
3
|
+
### 2.8.0 / 2021-06-17
|
4
|
+
|
5
|
+
#### Features
|
6
|
+
|
7
|
+
* create instance using processing units/node count ([#11379](https://www.github.com/googleapis/google-cloud-ruby/issues/11379))
|
8
|
+
* create instance using processing units/node count
|
9
|
+
* fix typo
|
10
|
+
* removed node count and processing unit validations
|
11
|
+
* update orignal value on instance save
|
12
|
+
* remove orignal_values to current_valuess
|
13
|
+
|
3
14
|
### 2.7.0 / 2021-06-09
|
4
15
|
|
5
16
|
#### Features
|
@@ -68,6 +68,7 @@ module Google
|
|
68
68
|
def initialize grpc, service
|
69
69
|
@grpc = grpc
|
70
70
|
@service = service
|
71
|
+
@current_values = grpc.to_h
|
71
72
|
end
|
72
73
|
|
73
74
|
# The unique identifier for the project.
|
@@ -134,6 +135,23 @@ module Google
|
|
134
135
|
end
|
135
136
|
alias node_count= nodes=
|
136
137
|
|
138
|
+
##
|
139
|
+
# The number of processing units allocated to this instance.
|
140
|
+
#
|
141
|
+
# @return [Integer]
|
142
|
+
def processing_units
|
143
|
+
@grpc.processing_units
|
144
|
+
end
|
145
|
+
|
146
|
+
##
|
147
|
+
# Updates number of processing units allocated to this instance.
|
148
|
+
#
|
149
|
+
# @param units [Integer] The number of processing units allocated
|
150
|
+
# to this instance.
|
151
|
+
def processing_units= units
|
152
|
+
@grpc.processing_units = units
|
153
|
+
end
|
154
|
+
|
137
155
|
##
|
138
156
|
# The current instance state. Possible values are `:CREATING` and
|
139
157
|
# `:READY`.
|
@@ -188,8 +206,50 @@ module Google
|
|
188
206
|
)
|
189
207
|
end
|
190
208
|
|
209
|
+
##
|
210
|
+
# Update changes.
|
211
|
+
# `display_name`, `labels`, `nodes`, `processing_units` can be
|
212
|
+
# updated. `processing_units` and `nodes` can be used interchangeably
|
213
|
+
# to update.
|
214
|
+
#
|
215
|
+
# @return [Instance::Job] The job representing the long-running,
|
216
|
+
# asynchronous processing of an instance update operation.
|
217
|
+
# @raise [ArgumentError] if both processing_units or nodes are specified.
|
218
|
+
#
|
219
|
+
# @example
|
220
|
+
# require "google/cloud/spanner"
|
221
|
+
#
|
222
|
+
# spanner = Google::Cloud::Spanner.new
|
223
|
+
#
|
224
|
+
# instance = spanner.instance "my-instance"
|
225
|
+
# instance.display_name = "prod-instance"
|
226
|
+
# instance.labels = { env: "prod", app: "api" }
|
227
|
+
# instance.nodes = 2
|
228
|
+
# # OR
|
229
|
+
# # instance.processing_units = 500
|
230
|
+
#
|
231
|
+
# job = instance.save
|
232
|
+
#
|
233
|
+
# job.done? #=> false
|
234
|
+
# job.reload! # API call
|
235
|
+
# job.done? #=> true
|
236
|
+
#
|
237
|
+
# if job.error?
|
238
|
+
# status = job.error
|
239
|
+
# else
|
240
|
+
# instance = job.instance
|
241
|
+
# end
|
242
|
+
#
|
191
243
|
def save
|
192
|
-
|
244
|
+
ensure_service!
|
245
|
+
|
246
|
+
field_mask = []
|
247
|
+
@current_values.each do |field, value|
|
248
|
+
field_mask << field unless @grpc[field.to_s] == value
|
249
|
+
end
|
250
|
+
|
251
|
+
job_grpc = service.update_instance @grpc, field_mask: field_mask
|
252
|
+
@current_values = @grpc.to_h
|
193
253
|
Instance::Job.from_grpc job_grpc, service
|
194
254
|
end
|
195
255
|
alias update save
|
@@ -177,7 +177,10 @@ module Google
|
|
177
177
|
# configuration. Values can be the `instance_config_id`, the full
|
178
178
|
# path, or an {Instance::Config} object. Required.
|
179
179
|
# @param [Integer] nodes The number of nodes allocated to this instance.
|
180
|
-
#
|
180
|
+
# Optional. Specify either `nodes` or `processing_units`
|
181
|
+
# @param [Integer] processing_units The number of processing units
|
182
|
+
# allocated to this instance. Optional. Specify either `nodes`
|
183
|
+
# or `processing_units`
|
181
184
|
# @param [Hash] labels Cloud Labels are a flexible and lightweight
|
182
185
|
# mechanism for organizing cloud resources into groups that reflect a
|
183
186
|
# customer's organizational needs and deployment strategies. Cloud
|
@@ -195,6 +198,7 @@ module Google
|
|
195
198
|
#
|
196
199
|
# @return [Instance::Job] The job representing the long-running,
|
197
200
|
# asynchronous processing of an instance create operation.
|
201
|
+
# @raise [ArgumentError] if both processing_units or nodes are specified.
|
198
202
|
#
|
199
203
|
# @example
|
200
204
|
# require "google/cloud/spanner"
|
@@ -217,14 +221,36 @@ module Google
|
|
217
221
|
# instance = job.instance
|
218
222
|
# end
|
219
223
|
#
|
224
|
+
# @example Create instance using processsing units
|
225
|
+
# require "google/cloud/spanner"
|
226
|
+
#
|
227
|
+
# spanner = Google::Cloud::Spanner.new
|
228
|
+
#
|
229
|
+
# job = spanner.create_instance "my-new-instance",
|
230
|
+
# name: "My New Instance",
|
231
|
+
# config: "regional-us-central1",
|
232
|
+
# processing_units: 500,
|
233
|
+
# labels: { production: :env }
|
234
|
+
#
|
235
|
+
# job.done? #=> false
|
236
|
+
# job.reload! # API call
|
237
|
+
# job.done? #=> true
|
238
|
+
#
|
239
|
+
# if job.error?
|
240
|
+
# status = job.error
|
241
|
+
# else
|
242
|
+
# instance = job.instance
|
243
|
+
# end
|
244
|
+
#
|
220
245
|
def create_instance instance_id, name: nil, config: nil, nodes: nil,
|
221
|
-
labels: nil
|
246
|
+
processing_units: nil, labels: nil
|
222
247
|
config = config.path if config.respond_to? :path
|
248
|
+
|
223
249
|
# Convert from possible Google::Protobuf::Map
|
224
250
|
labels = Hash[labels.map { |k, v| [String(k), String(v)] }] if labels
|
225
251
|
grpc = service.create_instance \
|
226
252
|
instance_id, name: name, config: config, nodes: nodes,
|
227
|
-
labels: labels
|
253
|
+
processing_units: processing_units, labels: labels
|
228
254
|
Instance::Job.from_grpc grpc, service
|
229
255
|
end
|
230
256
|
|
@@ -127,13 +127,15 @@ module Google
|
|
127
127
|
end
|
128
128
|
|
129
129
|
def create_instance instance_id, name: nil, config: nil, nodes: nil,
|
130
|
-
|
130
|
+
processing_units: nil, labels: nil,
|
131
|
+
call_options: nil
|
131
132
|
opts = default_options call_options: call_options
|
132
133
|
labels = Hash[labels.map { |k, v| [String(k), String(v)] }] if labels
|
133
134
|
|
134
135
|
create_obj = Admin::Instance::V1::Instance.new({
|
135
136
|
display_name: name, config: instance_config_path(config),
|
136
|
-
node_count: nodes,
|
137
|
+
node_count: nodes, processing_units: processing_units,
|
138
|
+
labels: labels
|
137
139
|
}.delete_if { |_, v| v.nil? })
|
138
140
|
|
139
141
|
request = {
|
@@ -144,12 +146,17 @@ module Google
|
|
144
146
|
instances.create_instance request, opts
|
145
147
|
end
|
146
148
|
|
147
|
-
def update_instance instance, call_options: nil
|
149
|
+
def update_instance instance, field_mask: nil, call_options: nil
|
148
150
|
opts = default_options call_options: call_options
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
151
|
+
|
152
|
+
if field_mask.nil? || field_mask.empty?
|
153
|
+
field_mask = %w[display_name node_count labels]
|
154
|
+
end
|
155
|
+
|
156
|
+
request = {
|
157
|
+
instance: instance,
|
158
|
+
field_mask: Google::Protobuf::FieldMask.new(paths: field_mask)
|
159
|
+
}
|
153
160
|
instances.update_instance request, opts
|
154
161
|
end
|
155
162
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: google-cloud-spanner
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.8.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mike Moore
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2021-06-
|
12
|
+
date: 2021-06-17 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: google-cloud-core
|