google-cloud-bigtable 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.yardopts +19 -0
- data/AUTHENTICATION.md +177 -0
- data/CHANGELOG.md +223 -0
- data/CODE_OF_CONDUCT.md +40 -0
- data/CONTRIBUTING.md +188 -0
- data/EMULATOR.md +30 -0
- data/LICENSE +201 -0
- data/LOGGING.md +32 -0
- data/OVERVIEW.md +400 -0
- data/TROUBLESHOOTING.md +31 -0
- data/lib/google-cloud-bigtable.rb +171 -0
- data/lib/google/bigtable/admin/v2/bigtable_instance_admin_pb.rb +145 -0
- data/lib/google/bigtable/admin/v2/bigtable_instance_admin_services_pb.rb +90 -0
- data/lib/google/bigtable/admin/v2/bigtable_table_admin_pb.rb +208 -0
- data/lib/google/bigtable/admin/v2/bigtable_table_admin_services_pb.rb +154 -0
- data/lib/google/bigtable/admin/v2/common_pb.rb +30 -0
- data/lib/google/bigtable/admin/v2/instance_pb.rb +74 -0
- data/lib/google/bigtable/admin/v2/table_pb.rb +127 -0
- data/lib/google/bigtable/v2/bigtable_pb.rb +113 -0
- data/lib/google/bigtable/v2/bigtable_services_pb.rb +68 -0
- data/lib/google/bigtable/v2/data_pb.rb +156 -0
- data/lib/google/cloud/bigtable.rb +184 -0
- data/lib/google/cloud/bigtable/admin.rb +202 -0
- data/lib/google/cloud/bigtable/admin/credentials.rb +27 -0
- data/lib/google/cloud/bigtable/admin/v2.rb +223 -0
- data/lib/google/cloud/bigtable/admin/v2/bigtable_instance_admin_client.rb +1451 -0
- data/lib/google/cloud/bigtable/admin/v2/bigtable_instance_admin_client_config.json +139 -0
- data/lib/google/cloud/bigtable/admin/v2/bigtable_table_admin_client.rb +1734 -0
- data/lib/google/cloud/bigtable/admin/v2/bigtable_table_admin_client_config.json +163 -0
- data/lib/google/cloud/bigtable/admin/v2/credentials.rb +51 -0
- data/lib/google/cloud/bigtable/admin/v2/doc/google/bigtable/admin/v2/bigtable_instance_admin.rb +297 -0
- data/lib/google/cloud/bigtable/admin/v2/doc/google/bigtable/admin/v2/bigtable_table_admin.rb +587 -0
- data/lib/google/cloud/bigtable/admin/v2/doc/google/bigtable/admin/v2/instance.rb +193 -0
- data/lib/google/cloud/bigtable/admin/v2/doc/google/bigtable/admin/v2/table.rb +303 -0
- data/lib/google/cloud/bigtable/admin/v2/doc/google/iam/v1/iam_policy.rb +64 -0
- data/lib/google/cloud/bigtable/admin/v2/doc/google/iam/v1/options.rb +33 -0
- data/lib/google/cloud/bigtable/admin/v2/doc/google/iam/v1/policy.rb +151 -0
- data/lib/google/cloud/bigtable/admin/v2/doc/google/longrunning/operations.rb +51 -0
- data/lib/google/cloud/bigtable/admin/v2/doc/google/protobuf/any.rb +131 -0
- data/lib/google/cloud/bigtable/admin/v2/doc/google/protobuf/duration.rb +91 -0
- data/lib/google/cloud/bigtable/admin/v2/doc/google/protobuf/empty.rb +29 -0
- data/lib/google/cloud/bigtable/admin/v2/doc/google/protobuf/field_mask.rb +222 -0
- data/lib/google/cloud/bigtable/admin/v2/doc/google/protobuf/timestamp.rb +113 -0
- data/lib/google/cloud/bigtable/admin/v2/doc/google/rpc/status.rb +39 -0
- data/lib/google/cloud/bigtable/admin/v2/doc/google/type/expr.rb +45 -0
- data/lib/google/cloud/bigtable/app_profile.rb +439 -0
- data/lib/google/cloud/bigtable/app_profile/job.rb +99 -0
- data/lib/google/cloud/bigtable/app_profile/list.rb +165 -0
- data/lib/google/cloud/bigtable/backup.rb +324 -0
- data/lib/google/cloud/bigtable/backup/job.rb +87 -0
- data/lib/google/cloud/bigtable/backup/list.rb +167 -0
- data/lib/google/cloud/bigtable/chunk_processor.rb +241 -0
- data/lib/google/cloud/bigtable/cluster.rb +390 -0
- data/lib/google/cloud/bigtable/cluster/job.rb +88 -0
- data/lib/google/cloud/bigtable/cluster/list.rb +171 -0
- data/lib/google/cloud/bigtable/column_family.rb +73 -0
- data/lib/google/cloud/bigtable/column_family_map.rb +426 -0
- data/lib/google/cloud/bigtable/column_range.rb +194 -0
- data/lib/google/cloud/bigtable/convert.rb +83 -0
- data/lib/google/cloud/bigtable/credentials.rb +25 -0
- data/lib/google/cloud/bigtable/errors.rb +38 -0
- data/lib/google/cloud/bigtable/gc_rule.rb +334 -0
- data/lib/google/cloud/bigtable/instance.rb +935 -0
- data/lib/google/cloud/bigtable/instance/cluster_map.rb +74 -0
- data/lib/google/cloud/bigtable/instance/job.rb +98 -0
- data/lib/google/cloud/bigtable/instance/list.rb +164 -0
- data/lib/google/cloud/bigtable/longrunning_job.rb +122 -0
- data/lib/google/cloud/bigtable/mutation_entry.rb +256 -0
- data/lib/google/cloud/bigtable/mutation_operations.rb +357 -0
- data/lib/google/cloud/bigtable/policy.rb +167 -0
- data/lib/google/cloud/bigtable/project.rb +471 -0
- data/lib/google/cloud/bigtable/read_modify_write_rule.rb +134 -0
- data/lib/google/cloud/bigtable/read_operations.rb +328 -0
- data/lib/google/cloud/bigtable/routing_policy.rb +172 -0
- data/lib/google/cloud/bigtable/row.rb +136 -0
- data/lib/google/cloud/bigtable/row_filter.rb +639 -0
- data/lib/google/cloud/bigtable/row_filter/chain_filter.rb +590 -0
- data/lib/google/cloud/bigtable/row_filter/condition_filter.rb +114 -0
- data/lib/google/cloud/bigtable/row_filter/interleave_filter.rb +621 -0
- data/lib/google/cloud/bigtable/row_filter/simple_filter.rb +287 -0
- data/lib/google/cloud/bigtable/row_range.rb +179 -0
- data/lib/google/cloud/bigtable/rows_mutator.rb +113 -0
- data/lib/google/cloud/bigtable/rows_reader.rb +200 -0
- data/lib/google/cloud/bigtable/sample_row_key.rb +85 -0
- data/lib/google/cloud/bigtable/service.rb +913 -0
- data/lib/google/cloud/bigtable/status.rb +76 -0
- data/lib/google/cloud/bigtable/table.rb +686 -0
- data/lib/google/cloud/bigtable/table/cluster_state.rb +125 -0
- data/lib/google/cloud/bigtable/table/list.rb +154 -0
- data/lib/google/cloud/bigtable/table/restore_job.rb +117 -0
- data/lib/google/cloud/bigtable/v2.rb +146 -0
- data/lib/google/cloud/bigtable/v2/bigtable_client.rb +591 -0
- data/lib/google/cloud/bigtable/v2/bigtable_client_config.json +83 -0
- data/lib/google/cloud/bigtable/v2/credentials.rb +46 -0
- data/lib/google/cloud/bigtable/v2/doc/google/bigtable/v2/bigtable.rb +290 -0
- data/lib/google/cloud/bigtable/v2/doc/google/bigtable/v2/data.rb +493 -0
- data/lib/google/cloud/bigtable/v2/doc/google/protobuf/any.rb +131 -0
- data/lib/google/cloud/bigtable/v2/doc/google/protobuf/wrappers.rb +34 -0
- data/lib/google/cloud/bigtable/v2/doc/google/rpc/status.rb +39 -0
- data/lib/google/cloud/bigtable/value_range.rb +181 -0
- data/lib/google/cloud/bigtable/version.rb +22 -0
- metadata +337 -0
@@ -0,0 +1,390 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Copyright 2018 Google LLC
|
4
|
+
#
|
5
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
6
|
+
# you may not use this file except in compliance with the License.
|
7
|
+
# You may obtain a copy of the License at
|
8
|
+
#
|
9
|
+
# https://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
#
|
11
|
+
# Unless required by applicable law or agreed to in writing, software
|
12
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
13
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14
|
+
# See the License for the specific language governing permissions and
|
15
|
+
# limitations under the License.
|
16
|
+
|
17
|
+
|
18
|
+
require "google/cloud/bigtable/backup"
|
19
|
+
require "google/cloud/bigtable/cluster/list"
|
20
|
+
require "google/cloud/bigtable/cluster/job"
|
21
|
+
|
22
|
+
module Google
|
23
|
+
module Cloud
|
24
|
+
module Bigtable
|
25
|
+
##
|
26
|
+
# # Cluster
|
27
|
+
#
|
28
|
+
# A configuration object describing how Cloud Bigtable should treat traffic
|
29
|
+
# from a particular end user application.
|
30
|
+
#
|
31
|
+
# @example
|
32
|
+
# require "google/cloud/bigtable"
|
33
|
+
#
|
34
|
+
# bigtable = Google::Cloud::Bigtable.new
|
35
|
+
#
|
36
|
+
# instance = bigtable.instance("my-instance")
|
37
|
+
# cluster = instance.cluster("my-cluster")
|
38
|
+
#
|
39
|
+
# # Update
|
40
|
+
# cluster.nodes = 3
|
41
|
+
# cluster.save
|
42
|
+
#
|
43
|
+
# # Delete
|
44
|
+
# cluster.delete
|
45
|
+
#
|
46
|
+
class Cluster
|
47
|
+
# @private
|
48
|
+
# The gRPC Service object.
|
49
|
+
attr_accessor :service
|
50
|
+
|
51
|
+
# @private
|
52
|
+
#
|
53
|
+
# Creates a new Cluster instance.
|
54
|
+
def initialize grpc, service
|
55
|
+
@grpc = grpc
|
56
|
+
@service = service
|
57
|
+
end
|
58
|
+
|
59
|
+
##
|
60
|
+
# The unique identifier for the project to which the cluster belongs.
|
61
|
+
#
|
62
|
+
# @return [String]
|
63
|
+
#
|
64
|
+
def project_id
|
65
|
+
@grpc.name.split("/")[1]
|
66
|
+
end
|
67
|
+
|
68
|
+
##
|
69
|
+
# The unique identifier for the instance to which the cluster belongs.
|
70
|
+
#
|
71
|
+
# @return [String]
|
72
|
+
#
|
73
|
+
def instance_id
|
74
|
+
@grpc.name.split("/")[3]
|
75
|
+
end
|
76
|
+
|
77
|
+
##
|
78
|
+
# The unique identifier for the cluster.
|
79
|
+
#
|
80
|
+
# @return [String]
|
81
|
+
#
|
82
|
+
def cluster_id
|
83
|
+
@grpc.name.split("/")[5]
|
84
|
+
end
|
85
|
+
|
86
|
+
##
|
87
|
+
# The unique name of the cluster. Value in the form
|
88
|
+
# `projects/<project_id>/instances/<instance_id>/clusters/<cluster_id>`.
|
89
|
+
#
|
90
|
+
# @return [String]
|
91
|
+
#
|
92
|
+
def path
|
93
|
+
@grpc.name
|
94
|
+
end
|
95
|
+
|
96
|
+
##
|
97
|
+
# The current state of the cluster.
|
98
|
+
# Possible values are
|
99
|
+
# `:CREATING`, `:READY`, `:STATE_NOT_KNOWN`, `:RESIZING`, `:DISABLED`.
|
100
|
+
#
|
101
|
+
# @return [Symbol]
|
102
|
+
#
|
103
|
+
def state
|
104
|
+
@grpc.state
|
105
|
+
end
|
106
|
+
|
107
|
+
##
|
108
|
+
# The cluster has been successfully created and is ready to serve requests.
|
109
|
+
#
|
110
|
+
# @return [Boolean]
|
111
|
+
#
|
112
|
+
def ready?
|
113
|
+
state == :READY
|
114
|
+
end
|
115
|
+
|
116
|
+
##
|
117
|
+
# The cluster is currently being created, and may be destroyed if the
|
118
|
+
# creation process encounters an error.
|
119
|
+
#
|
120
|
+
# @return [Boolean]
|
121
|
+
#
|
122
|
+
def creating?
|
123
|
+
state == :CREATING
|
124
|
+
end
|
125
|
+
|
126
|
+
##
|
127
|
+
# The cluster is currently being resized, and may revert to its previous
|
128
|
+
# node count if the process encounters an error.
|
129
|
+
# A cluster is still capable of serving requests while being resized,
|
130
|
+
# but may perform as if its number of allocated nodes is
|
131
|
+
# between the starting and requested states.
|
132
|
+
#
|
133
|
+
# @return [Boolean]
|
134
|
+
#
|
135
|
+
def resizing?
|
136
|
+
state == :RESIZING
|
137
|
+
end
|
138
|
+
|
139
|
+
##
|
140
|
+
# The cluster has no backing nodes. The data (tables) still
|
141
|
+
# exist, but no operations can be performed on the cluster.
|
142
|
+
#
|
143
|
+
# @return [Boolean]
|
144
|
+
#
|
145
|
+
def disabled?
|
146
|
+
state == :DISABLED
|
147
|
+
end
|
148
|
+
|
149
|
+
##
|
150
|
+
# The number of nodes allocated to this cluster.
|
151
|
+
#
|
152
|
+
# @return [Integer]
|
153
|
+
#
|
154
|
+
def nodes
|
155
|
+
@grpc.serve_nodes
|
156
|
+
end
|
157
|
+
|
158
|
+
##
|
159
|
+
# The number of nodes allocated to this cluster. More nodes enable higher
|
160
|
+
# throughput and more consistent performance.
|
161
|
+
#
|
162
|
+
# @param serve_nodes [Integer] Number of nodes
|
163
|
+
#
|
164
|
+
def nodes= serve_nodes
|
165
|
+
@grpc.serve_nodes = serve_nodes
|
166
|
+
end
|
167
|
+
|
168
|
+
##
|
169
|
+
# The type of storage used by this cluster to serve its
|
170
|
+
# parent instance's tables, unless explicitly overridden.
|
171
|
+
# Valid values are `:SSD`(Flash (SSD) storage should be used),
|
172
|
+
# `:HDD`(Magnetic drive (HDD) storage should be used)
|
173
|
+
#
|
174
|
+
# @return [Symbol]
|
175
|
+
#
|
176
|
+
def storage_type
|
177
|
+
@grpc.default_storage_type
|
178
|
+
end
|
179
|
+
|
180
|
+
##
|
181
|
+
# Cluster location.
|
182
|
+
# For example, "us-east1-b"
|
183
|
+
#
|
184
|
+
# @return [String]
|
185
|
+
#
|
186
|
+
def location
|
187
|
+
@grpc.location.split("/")[3]
|
188
|
+
end
|
189
|
+
|
190
|
+
##
|
191
|
+
# Cluster location path in form of
|
192
|
+
# `projects/<project_id>/locations/<zone>`
|
193
|
+
#
|
194
|
+
# @return [String]
|
195
|
+
#
|
196
|
+
def location_path
|
197
|
+
@grpc.location
|
198
|
+
end
|
199
|
+
|
200
|
+
##
|
201
|
+
# Creates a new Cloud Bigtable Backup.
|
202
|
+
#
|
203
|
+
# @param source_table [Table, String] The table object, or the name of the table,
|
204
|
+
# from which the backup is to be created. The table needs to be in the same
|
205
|
+
# instance as the backup. Required.
|
206
|
+
# @param backup_id [String] The id of the backup to be created. This string must
|
207
|
+
# be between 1 and 50 characters in length and match the regex
|
208
|
+
# `[_a-zA-Z0-9][-_.a-zA-Z0-9]*`. Required.
|
209
|
+
# @param expire_time [Time] The expiration time of the backup, with microseconds
|
210
|
+
# granularity that must be at least 6 hours and at most 30 days
|
211
|
+
# from the time the request is received. Once the `expire_time`
|
212
|
+
# has passed, Cloud Bigtable will delete the backup and free the
|
213
|
+
# resources used by the backup. Required.
|
214
|
+
# @return [Google::Cloud::Bigtable::Backup::Job]
|
215
|
+
# The job representing the long-running, asynchronous processing of
|
216
|
+
# a backup create operation.
|
217
|
+
#
|
218
|
+
# @example
|
219
|
+
# require "google/cloud/bigtable"
|
220
|
+
#
|
221
|
+
# bigtable = Google::Cloud::Bigtable.new
|
222
|
+
# instance = bigtable.instance("my-instance")
|
223
|
+
# cluster = instance.cluster("my-cluster")
|
224
|
+
# table = instance.table("my-table")
|
225
|
+
#
|
226
|
+
# expire_time = Time.now + 60 * 60 * 7
|
227
|
+
# job = cluster.create_backup(table, "my-backup", expire_time)
|
228
|
+
#
|
229
|
+
# job.wait_until_done!
|
230
|
+
# job.done? #=> true
|
231
|
+
#
|
232
|
+
# if job.error?
|
233
|
+
# status = job.error
|
234
|
+
# else
|
235
|
+
# backup = job.backup
|
236
|
+
# end
|
237
|
+
#
|
238
|
+
def create_backup source_table, backup_id, expire_time
|
239
|
+
source_table_id = source_table.respond_to?(:name) ? source_table.name : source_table
|
240
|
+
grpc = service.create_backup instance_id: instance_id,
|
241
|
+
cluster_id: cluster_id,
|
242
|
+
backup_id: backup_id,
|
243
|
+
source_table_id: source_table_id,
|
244
|
+
expire_time: expire_time
|
245
|
+
Backup::Job.from_grpc grpc, service
|
246
|
+
end
|
247
|
+
|
248
|
+
##
|
249
|
+
# Gets a backup in the cluster.
|
250
|
+
#
|
251
|
+
# @param backup_id [String] The unique ID of the requested backup.
|
252
|
+
#
|
253
|
+
# @return [Google::Cloud::Bigtable::Backup, nil] The backup object, or `nil` if not found in the service.
|
254
|
+
#
|
255
|
+
# @example
|
256
|
+
# require "google/cloud/bigtable"
|
257
|
+
#
|
258
|
+
# bigtable = Google::Cloud::Bigtable.new
|
259
|
+
#
|
260
|
+
# instance = bigtable.instance("my-instance")
|
261
|
+
# cluster = instance.cluster("my-cluster")
|
262
|
+
#
|
263
|
+
# backup = cluster.backup("my-backup")
|
264
|
+
#
|
265
|
+
# if backup
|
266
|
+
# puts backup.backup_id
|
267
|
+
# end
|
268
|
+
#
|
269
|
+
def backup backup_id
|
270
|
+
grpc = service.get_backup instance_id, cluster_id, backup_id
|
271
|
+
Backup.from_grpc grpc, service
|
272
|
+
rescue Google::Cloud::NotFoundError
|
273
|
+
nil
|
274
|
+
end
|
275
|
+
|
276
|
+
##
|
277
|
+
# Lists all backups in the cluster.
|
278
|
+
#
|
279
|
+
# @return [Array<Google::Cloud::Bigtable::Backup>] (See {Google::Cloud::Bigtable::Backup::List})
|
280
|
+
#
|
281
|
+
# @example
|
282
|
+
# require "google/cloud/bigtable"
|
283
|
+
#
|
284
|
+
# bigtable = Google::Cloud::Bigtable.new
|
285
|
+
#
|
286
|
+
# instance = bigtable.instance("my-instance")
|
287
|
+
# cluster = instance.cluster("my-cluster")
|
288
|
+
#
|
289
|
+
# cluster.backups.all do |backup|
|
290
|
+
# puts backup.backup_id
|
291
|
+
# end
|
292
|
+
#
|
293
|
+
def backups
|
294
|
+
grpc = service.list_backups instance_id, cluster_id
|
295
|
+
Backup::List.from_grpc grpc, service
|
296
|
+
end
|
297
|
+
|
298
|
+
##
|
299
|
+
# Updates the cluster.
|
300
|
+
#
|
301
|
+
# `serve_nodes` is the only updatable field.
|
302
|
+
#
|
303
|
+
# @return [Google::Cloud::Bigtable::Cluster::Job]
|
304
|
+
# The job representing the long-running, asynchronous processing of
|
305
|
+
# an update cluster operation.
|
306
|
+
#
|
307
|
+
# @example
|
308
|
+
# require "google/cloud/bigtable"
|
309
|
+
#
|
310
|
+
# bigtable = Google::Cloud::Bigtable.new
|
311
|
+
#
|
312
|
+
# instance = bigtable.instance("my-instance")
|
313
|
+
# cluster = instance.cluster("my-cluster")
|
314
|
+
# cluster.nodes = 3
|
315
|
+
# job = cluster.save
|
316
|
+
#
|
317
|
+
# job.done? #=> false
|
318
|
+
#
|
319
|
+
# # To block until the operation completes.
|
320
|
+
# job.wait_until_done!
|
321
|
+
# job.done? #=> true
|
322
|
+
#
|
323
|
+
# if job.error?
|
324
|
+
# status = job.error
|
325
|
+
# else
|
326
|
+
# cluster = job.cluster
|
327
|
+
# end
|
328
|
+
#
|
329
|
+
def save
|
330
|
+
ensure_service!
|
331
|
+
grpc = service.update_cluster instance_id, cluster_id, location_path, nodes
|
332
|
+
Cluster::Job.from_grpc grpc, service
|
333
|
+
end
|
334
|
+
alias update save
|
335
|
+
|
336
|
+
##
|
337
|
+
# Reloads cluster data.
|
338
|
+
#
|
339
|
+
# @return [Google::Cloud::Bigtable::Cluster]
|
340
|
+
#
|
341
|
+
def reload!
|
342
|
+
@grpc = service.get_cluster instance_id, cluster_id
|
343
|
+
self
|
344
|
+
end
|
345
|
+
|
346
|
+
##
|
347
|
+
# Permanently deletes the cluster.
|
348
|
+
#
|
349
|
+
# @return [Boolean] Returns `true` if the cluster was deleted.
|
350
|
+
#
|
351
|
+
# @example
|
352
|
+
# require "google/cloud/bigtable"
|
353
|
+
#
|
354
|
+
# bigtable = Google::Cloud::Bigtable.new
|
355
|
+
#
|
356
|
+
# instance = bigtable.instance("my-instance")
|
357
|
+
# cluster = instance.cluster("my-cluster")
|
358
|
+
# cluster.delete
|
359
|
+
#
|
360
|
+
def delete
|
361
|
+
ensure_service!
|
362
|
+
service.delete_cluster instance_id, cluster_id
|
363
|
+
true
|
364
|
+
end
|
365
|
+
|
366
|
+
# @private
|
367
|
+
#
|
368
|
+
# Creates a new Cluster instance from a
|
369
|
+
# Google::Bigtable::Admin::V2::Cluster.
|
370
|
+
#
|
371
|
+
# @param grpc [Google::Bigtable::Admin::V2::Cluster]
|
372
|
+
# @param service [Google::Cloud::Bigtable::Service]
|
373
|
+
# @return [Google::Cloud::Bigtable::Cluster]
|
374
|
+
def self.from_grpc grpc, service
|
375
|
+
new grpc, service
|
376
|
+
end
|
377
|
+
|
378
|
+
protected
|
379
|
+
|
380
|
+
# @private
|
381
|
+
#
|
382
|
+
# Raise an error unless an active connection to the service is
|
383
|
+
# available.
|
384
|
+
def ensure_service!
|
385
|
+
raise "Must have active connection to service" unless service
|
386
|
+
end
|
387
|
+
end
|
388
|
+
end
|
389
|
+
end
|
390
|
+
end
|
@@ -0,0 +1,88 @@
|
|
1
|
+
# Copyright 2018 Google LLC
|
2
|
+
#
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
# you may not use this file except in compliance with the License.
|
5
|
+
# You may obtain a copy of the License at
|
6
|
+
#
|
7
|
+
# https://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
#
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
# See the License for the specific language governing permissions and
|
13
|
+
# limitations under the License.
|
14
|
+
|
15
|
+
|
16
|
+
module Google
|
17
|
+
module Cloud
|
18
|
+
module Bigtable
|
19
|
+
class Cluster
|
20
|
+
##
|
21
|
+
# # Job
|
22
|
+
#
|
23
|
+
# A resource representing the long-running, asynchronous processing of
|
24
|
+
# an cluster create or update operation. The job can be refreshed to
|
25
|
+
# retrieve the cluster object once the operation has been completed.
|
26
|
+
#
|
27
|
+
# See {Instance#create_cluster} and {Cluster#save}.
|
28
|
+
#
|
29
|
+
# @see https://cloud.google.com/bigtable/docs/reference/admin/rpc/google.longrunning#google.longrunning.Operation
|
30
|
+
# Long-running Operation
|
31
|
+
#
|
32
|
+
# @example
|
33
|
+
# require "google/cloud/bigtable"
|
34
|
+
#
|
35
|
+
# bigtable = Google::Cloud::Bigtable.new
|
36
|
+
#
|
37
|
+
# instance = bigtable.instance("my-instance")
|
38
|
+
# job = instance.create_cluster(
|
39
|
+
# "my-new-cluster",
|
40
|
+
# "us-east-1b",
|
41
|
+
# nodes: 3,
|
42
|
+
# storage_type: :SSD
|
43
|
+
# )
|
44
|
+
#
|
45
|
+
# job.done? #=> false
|
46
|
+
# job.reload! # API call
|
47
|
+
# job.done? #=> true
|
48
|
+
#
|
49
|
+
# # OR wail until complete
|
50
|
+
# job.wait_until_done!
|
51
|
+
#
|
52
|
+
# if job.error?
|
53
|
+
# status = job.error
|
54
|
+
# else
|
55
|
+
# cluster = job.cluster
|
56
|
+
# end
|
57
|
+
#
|
58
|
+
class Job < LongrunningJob
|
59
|
+
##
|
60
|
+
# Gets the cluster object from job results
|
61
|
+
#
|
62
|
+
# @return [Google::Cloud::Bigtable::Cluster, nil] The cluster instance, or
|
63
|
+
# `nil` if the operation is not complete.
|
64
|
+
#
|
65
|
+
# @example
|
66
|
+
# require "google/cloud/bigtable"
|
67
|
+
#
|
68
|
+
# bigtable = Google::Cloud::Bigtable.new
|
69
|
+
#
|
70
|
+
# instance = bigtable.instance("my-instance")
|
71
|
+
# job = instance.create_cluster(
|
72
|
+
# "my-new-cluster",
|
73
|
+
# "us-east-1b",
|
74
|
+
# nodes: 3,
|
75
|
+
# storage_type: :SSD
|
76
|
+
# )
|
77
|
+
#
|
78
|
+
# job.wait_until_done!
|
79
|
+
# cluster = job.cluster
|
80
|
+
#
|
81
|
+
def cluster
|
82
|
+
Cluster.from_grpc results, service if results
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|