google-cloud-bigtable 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.yardopts +10 -0
- data/LICENSE +201 -0
- data/README.md +65 -0
- data/lib/google/bigtable/admin/v2/bigtable_instance_admin_pb.rb +139 -0
- data/lib/google/bigtable/admin/v2/bigtable_instance_admin_services_pb.rb +85 -0
- data/lib/google/bigtable/admin/v2/bigtable_table_admin_pb.rb +137 -0
- data/lib/google/bigtable/admin/v2/bigtable_table_admin_services_pb.rb +117 -0
- data/lib/google/bigtable/admin/v2/common_pb.rb +24 -0
- data/lib/google/bigtable/admin/v2/instance_pb.rb +72 -0
- data/lib/google/bigtable/admin/v2/table_pb.rb +88 -0
- data/lib/google/bigtable/v2/bigtable_pb.rb +109 -0
- data/lib/google/bigtable/v2/bigtable_services_pb.rb +67 -0
- data/lib/google/bigtable/v2/data_pb.rb +155 -0
- data/lib/google/cloud/bigtable/admin/credentials.rb +26 -0
- data/lib/google/cloud/bigtable/admin/v2/bigtable_instance_admin_client.rb +1417 -0
- data/lib/google/cloud/bigtable/admin/v2/bigtable_instance_admin_client_config.json +123 -0
- data/lib/google/cloud/bigtable/admin/v2/bigtable_table_admin_client.rb +1079 -0
- data/lib/google/cloud/bigtable/admin/v2/bigtable_table_admin_client_config.json +109 -0
- data/lib/google/cloud/bigtable/admin/v2/credentials.rb +50 -0
- data/lib/google/cloud/bigtable/admin/v2/doc/google/bigtable/admin/v2/bigtable_instance_admin.rb +279 -0
- data/lib/google/cloud/bigtable/admin/v2/doc/google/bigtable/admin/v2/bigtable_table_admin.rb +353 -0
- data/lib/google/cloud/bigtable/admin/v2/doc/google/bigtable/admin/v2/instance.rb +194 -0
- data/lib/google/cloud/bigtable/admin/v2/doc/google/bigtable/admin/v2/table.rb +209 -0
- data/lib/google/cloud/bigtable/admin/v2/doc/google/iam/v1/iam_policy.rb +62 -0
- data/lib/google/cloud/bigtable/admin/v2/doc/google/iam/v1/policy.rb +127 -0
- data/lib/google/cloud/bigtable/admin/v2/doc/google/longrunning/operations.rb +92 -0
- data/lib/google/cloud/bigtable/admin/v2/doc/google/protobuf/any.rb +124 -0
- data/lib/google/cloud/bigtable/admin/v2/doc/google/protobuf/duration.rb +90 -0
- data/lib/google/cloud/bigtable/admin/v2/doc/google/protobuf/empty.rb +28 -0
- data/lib/google/cloud/bigtable/admin/v2/doc/google/protobuf/field_mask.rb +223 -0
- data/lib/google/cloud/bigtable/admin/v2/doc/google/protobuf/timestamp.rb +106 -0
- data/lib/google/cloud/bigtable/admin/v2/doc/google/rpc/status.rb +83 -0
- data/lib/google/cloud/bigtable/admin/v2.rb +200 -0
- data/lib/google/cloud/bigtable/admin.rb +196 -0
- data/lib/google/cloud/bigtable/app_profile/job.rb +102 -0
- data/lib/google/cloud/bigtable/app_profile/list.rb +159 -0
- data/lib/google/cloud/bigtable/app_profile.rb +373 -0
- data/lib/google/cloud/bigtable/chunk_processor.rb +253 -0
- data/lib/google/cloud/bigtable/cluster/job.rb +92 -0
- data/lib/google/cloud/bigtable/cluster/list.rb +169 -0
- data/lib/google/cloud/bigtable/cluster.rb +264 -0
- data/lib/google/cloud/bigtable/column_family.rb +280 -0
- data/lib/google/cloud/bigtable/column_range.rb +186 -0
- data/lib/google/cloud/bigtable/convert.rb +75 -0
- data/lib/google/cloud/bigtable/credentials.rb +24 -0
- data/lib/google/cloud/bigtable/errors.rb +35 -0
- data/lib/google/cloud/bigtable/gc_rule.rb +215 -0
- data/lib/google/cloud/bigtable/instance/cluster_map.rb +70 -0
- data/lib/google/cloud/bigtable/instance/job.rb +97 -0
- data/lib/google/cloud/bigtable/instance/list.rb +159 -0
- data/lib/google/cloud/bigtable/instance.rb +921 -0
- data/lib/google/cloud/bigtable/longrunning_job.rb +105 -0
- data/lib/google/cloud/bigtable/mutation_entry.rb +244 -0
- data/lib/google/cloud/bigtable/mutation_operations.rb +338 -0
- data/lib/google/cloud/bigtable/policy.rb +163 -0
- data/lib/google/cloud/bigtable/project.rb +580 -0
- data/lib/google/cloud/bigtable/read_modify_write_rule.rb +129 -0
- data/lib/google/cloud/bigtable/read_operations.rb +345 -0
- data/lib/google/cloud/bigtable/row.rb +125 -0
- data/lib/google/cloud/bigtable/row_filter/chain_filter.rb +539 -0
- data/lib/google/cloud/bigtable/row_filter/condition_filter.rb +108 -0
- data/lib/google/cloud/bigtable/row_filter/interleave_filter.rb +570 -0
- data/lib/google/cloud/bigtable/row_filter/simple_filter.rb +273 -0
- data/lib/google/cloud/bigtable/row_filter.rb +593 -0
- data/lib/google/cloud/bigtable/row_range.rb +174 -0
- data/lib/google/cloud/bigtable/rows_mutator.rb +120 -0
- data/lib/google/cloud/bigtable/rows_reader.rb +196 -0
- data/lib/google/cloud/bigtable/sample_row_key.rb +82 -0
- data/lib/google/cloud/bigtable/service.rb +817 -0
- data/lib/google/cloud/bigtable/table/cluster_state.rb +93 -0
- data/lib/google/cloud/bigtable/table/column_family_map.rb +68 -0
- data/lib/google/cloud/bigtable/table/list.rb +147 -0
- data/lib/google/cloud/bigtable/table.rb +676 -0
- data/lib/google/cloud/bigtable/v2/bigtable_client.rb +579 -0
- data/lib/google/cloud/bigtable/v2/bigtable_client_config.json +65 -0
- data/lib/google/cloud/bigtable/v2/credentials.rb +45 -0
- data/lib/google/cloud/bigtable/v2/doc/google/bigtable/v2/bigtable.rb +286 -0
- data/lib/google/cloud/bigtable/v2/doc/google/bigtable/v2/data.rb +492 -0
- data/lib/google/cloud/bigtable/v2/doc/google/protobuf/any.rb +124 -0
- data/lib/google/cloud/bigtable/v2/doc/google/protobuf/wrappers.rb +89 -0
- data/lib/google/cloud/bigtable/v2/doc/google/rpc/status.rb +83 -0
- data/lib/google/cloud/bigtable/v2.rb +132 -0
- data/lib/google/cloud/bigtable/value_range.rb +175 -0
- data/lib/google/cloud/bigtable/version.rb +22 -0
- data/lib/google/cloud/bigtable.rb +223 -0
- data/lib/google-cloud-bigtable.rb +167 -0
- metadata +283 -0
@@ -0,0 +1,92 @@
|
|
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
|
+
# # Job
|
21
|
+
#
|
22
|
+
# A resource representing the long-running, asynchronous processing of
|
23
|
+
# an cluster create or update operation. The job can be refreshed to
|
24
|
+
# retrieve the cluster object once the operation has been completed.
|
25
|
+
#
|
26
|
+
# See {Instance#create_cluster} and {Cluster#save}.
|
27
|
+
#
|
28
|
+
# @see https://cloud.google.com/bigtable/docs/reference/admin/rpc/google.longrunning#google.longrunning.Operation
|
29
|
+
# Long-running Operation
|
30
|
+
#
|
31
|
+
# @example
|
32
|
+
# require "google/cloud/bigtable"
|
33
|
+
#
|
34
|
+
# bigtable = Google::Cloud::Bigtable.new
|
35
|
+
#
|
36
|
+
# instance = bigtable.instance("my-instance")
|
37
|
+
# job = instance.create_cluster(
|
38
|
+
# "my-new-cluster",
|
39
|
+
# "us-east-1b",
|
40
|
+
# nodes: 3,
|
41
|
+
# storage_type: :SSD
|
42
|
+
# )
|
43
|
+
#
|
44
|
+
# job.done? #=> false
|
45
|
+
# job.reload! # API call
|
46
|
+
# job.done? #=> true
|
47
|
+
#
|
48
|
+
# # OR wail until complete
|
49
|
+
# job.wait_until_done!
|
50
|
+
#
|
51
|
+
# if job.error?
|
52
|
+
# status = job.error
|
53
|
+
# else
|
54
|
+
# cluster = job.cluster
|
55
|
+
# end
|
56
|
+
#
|
57
|
+
class Job < LongrunningJob
|
58
|
+
# Get the cluster object from job results
|
59
|
+
#
|
60
|
+
# @return [Google::Cloud::Bigtable::Cluster, nil] The cluster instance, or
|
61
|
+
# `nil` if the operation is not complete.
|
62
|
+
#
|
63
|
+
# @example
|
64
|
+
# require "google/cloud/bigtable"
|
65
|
+
#
|
66
|
+
# bigtable = Google::Cloud::Bigtable.new
|
67
|
+
#
|
68
|
+
# instance = bigtable.instance("my-instance")
|
69
|
+
# job = instance.create_cluster(
|
70
|
+
# "my-new-cluster",
|
71
|
+
# "us-east-1b",
|
72
|
+
# nodes: 3,
|
73
|
+
# storage_type: :SSD
|
74
|
+
# )
|
75
|
+
#
|
76
|
+
# job.done? #=> false
|
77
|
+
# job.reload!
|
78
|
+
# job.done? #=> true
|
79
|
+
#
|
80
|
+
# # OR wait utill complete
|
81
|
+
#
|
82
|
+
# job.wait_until_done!
|
83
|
+
# cluster = job.cluster
|
84
|
+
#
|
85
|
+
def cluster
|
86
|
+
Cluster.from_grpc(results, service) if results
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
@@ -0,0 +1,169 @@
|
|
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 "delegate"
|
19
|
+
|
20
|
+
module Google
|
21
|
+
module Cloud
|
22
|
+
module Bigtable
|
23
|
+
class Cluster
|
24
|
+
# Cluster::List is a special case Array with additional
|
25
|
+
# values.
|
26
|
+
class List < DelegateClass(::Array)
|
27
|
+
# @private
|
28
|
+
# The gRPC Service object.
|
29
|
+
attr_accessor :service
|
30
|
+
|
31
|
+
# @private
|
32
|
+
# Instance id
|
33
|
+
attr_accessor :instance_id
|
34
|
+
|
35
|
+
# If not empty, indicates that there are more records that match
|
36
|
+
# the request and this value should be passed to continue.
|
37
|
+
attr_accessor :token
|
38
|
+
|
39
|
+
# Locations from which Cluster information could not be retrieved,
|
40
|
+
# due to an outage or some other transient condition.
|
41
|
+
# Clusters from these locations may be missing from `clusters`,
|
42
|
+
# or may only have partial information returned.
|
43
|
+
attr_accessor :failed_locations
|
44
|
+
|
45
|
+
# @private
|
46
|
+
# Create a new Cluster::List with an array of
|
47
|
+
# Cluster instances.
|
48
|
+
def initialize arr = []
|
49
|
+
super(arr)
|
50
|
+
end
|
51
|
+
|
52
|
+
# Whether there is a next page of instances.
|
53
|
+
#
|
54
|
+
# @return [Boolean]
|
55
|
+
#
|
56
|
+
# @example
|
57
|
+
# require "google/cloud/bigtable"
|
58
|
+
#
|
59
|
+
# bigtable = Google::Cloud::Bigtable.new
|
60
|
+
#
|
61
|
+
# clusters = bigtable.clusters("instance-id")
|
62
|
+
# if clusters.next?
|
63
|
+
# next_clusters = clusters.next
|
64
|
+
# end
|
65
|
+
def next?
|
66
|
+
!token.nil?
|
67
|
+
end
|
68
|
+
|
69
|
+
# Retrieve the next page of clusters.
|
70
|
+
#
|
71
|
+
# @return [Cluster::List] The list of clusters.
|
72
|
+
#
|
73
|
+
# @example
|
74
|
+
# require "google/cloud/bigtable"
|
75
|
+
#
|
76
|
+
# bigtable = Google::Cloud::Bigtable.new
|
77
|
+
#
|
78
|
+
# clusters = bigtable.clusters("instance-id")
|
79
|
+
# if instances.next?
|
80
|
+
# next_clusters = clusters.next
|
81
|
+
# end
|
82
|
+
def next
|
83
|
+
return nil unless next?
|
84
|
+
ensure_service!
|
85
|
+
grpc = service.list_clusters(instance_id, token: token)
|
86
|
+
next_list = self.class.from_grpc(
|
87
|
+
grpc,
|
88
|
+
service,
|
89
|
+
instance_id: instance_id
|
90
|
+
)
|
91
|
+
if failed_locations
|
92
|
+
next_list.failed_locations.concat(failed_locations.map(&:to_s))
|
93
|
+
end
|
94
|
+
next_list
|
95
|
+
end
|
96
|
+
|
97
|
+
# Retrieves remaining results by repeatedly invoking {#next} until
|
98
|
+
# {#next?} returns `false`. Calls the given block once for each
|
99
|
+
# result, which is passed as the argument to the block.
|
100
|
+
#
|
101
|
+
# An Enumerator is returned if no block is given.
|
102
|
+
#
|
103
|
+
# This method will make repeated API calls until all remaining results
|
104
|
+
# are retrieved. (Unlike `#each`, for example, which merely iterates
|
105
|
+
# over the results returned by a single API call.) Use with caution.
|
106
|
+
#
|
107
|
+
# @yield [cluster] The block for accessing each cluster.
|
108
|
+
# @yieldparam [Cluster] cluster The cluster object.
|
109
|
+
#
|
110
|
+
# @return [Enumerator]
|
111
|
+
#
|
112
|
+
# @example Iterating each cluster by passing a block:
|
113
|
+
# require "google/cloud/bigtable"
|
114
|
+
#
|
115
|
+
# bigtable = Google::Cloud::Bigtable.new
|
116
|
+
#
|
117
|
+
# bigtable.clusters("instance-id").all do |cluster|
|
118
|
+
# puts cluster.cluster_id
|
119
|
+
# end
|
120
|
+
#
|
121
|
+
# @example Using the enumerator by not passing a block:
|
122
|
+
# require "google/cloud/bigtable"
|
123
|
+
#
|
124
|
+
# bigtable = Google::Cloud::Bigtable.new
|
125
|
+
#
|
126
|
+
# all_cluster_ids = bigtable.clusters("instance-id").all.map do |cluster|
|
127
|
+
# puts cluster.instance_id
|
128
|
+
# end
|
129
|
+
#
|
130
|
+
def all
|
131
|
+
return enum_for(:all) unless block_given?
|
132
|
+
|
133
|
+
results = self
|
134
|
+
loop do
|
135
|
+
results.each { |r| yield r }
|
136
|
+
break unless results.next?
|
137
|
+
results = results.next
|
138
|
+
end
|
139
|
+
end
|
140
|
+
|
141
|
+
# @private
|
142
|
+
#
|
143
|
+
# New Cluster::List from a Google::Bigtable::Admin::V2::ListClustersResponse object.
|
144
|
+
def self.from_grpc grpc, service, instance_id: nil
|
145
|
+
clusters = List.new(Array(grpc.clusters).map do |cluster|
|
146
|
+
Cluster.from_grpc(cluster, service)
|
147
|
+
end)
|
148
|
+
token = grpc.next_page_token
|
149
|
+
token = nil if token == "".freeze
|
150
|
+
clusters.token = token
|
151
|
+
clusters.instance_id = instance_id
|
152
|
+
clusters.service = service
|
153
|
+
clusters.failed_locations = grpc.failed_locations.map(&:to_s)
|
154
|
+
clusters
|
155
|
+
end
|
156
|
+
|
157
|
+
protected
|
158
|
+
|
159
|
+
# @private
|
160
|
+
#
|
161
|
+
# Raise an error unless an active service is available.
|
162
|
+
def ensure_service!
|
163
|
+
raise "Must have active connection" unless service
|
164
|
+
end
|
165
|
+
end
|
166
|
+
end
|
167
|
+
end
|
168
|
+
end
|
169
|
+
end
|
@@ -0,0 +1,264 @@
|
|
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/cluster/list"
|
19
|
+
require "google/cloud/bigtable/cluster/job"
|
20
|
+
|
21
|
+
module Google
|
22
|
+
module Cloud
|
23
|
+
module Bigtable
|
24
|
+
# # Cluster
|
25
|
+
#
|
26
|
+
# A configuration object describing how Cloud Bigtable should treat traffic
|
27
|
+
# from a particular end user application.
|
28
|
+
#
|
29
|
+
# @example
|
30
|
+
# require "google/cloud/bigtable"
|
31
|
+
#
|
32
|
+
# bigtable = Google::Cloud::Bigtable.new
|
33
|
+
#
|
34
|
+
# instance = bigtable.instance("my-instance")
|
35
|
+
# cluster = instance.cluster("my-cluster")
|
36
|
+
#
|
37
|
+
# # Update
|
38
|
+
# cluster.nodes = 3
|
39
|
+
# cluster.save
|
40
|
+
#
|
41
|
+
# # Delete
|
42
|
+
# cluster.delete
|
43
|
+
#
|
44
|
+
class Cluster
|
45
|
+
# @private
|
46
|
+
# The gRPC Service object.
|
47
|
+
attr_accessor :service
|
48
|
+
|
49
|
+
# @private
|
50
|
+
#
|
51
|
+
# Creates a new Cluster instance.
|
52
|
+
def initialize grpc, service
|
53
|
+
@grpc = grpc
|
54
|
+
@service = service
|
55
|
+
end
|
56
|
+
|
57
|
+
# The unique identifier for the project.
|
58
|
+
#
|
59
|
+
# @return [String]
|
60
|
+
def project_id
|
61
|
+
@grpc.name.split("/")[1]
|
62
|
+
end
|
63
|
+
|
64
|
+
# The unique identifier for the instance.
|
65
|
+
#
|
66
|
+
# @return [String]
|
67
|
+
def instance_id
|
68
|
+
@grpc.name.split("/")[3]
|
69
|
+
end
|
70
|
+
|
71
|
+
# The unique identifier for the cluster.
|
72
|
+
#
|
73
|
+
# @return [String]
|
74
|
+
def cluster_id
|
75
|
+
@grpc.name.split("/")[5]
|
76
|
+
end
|
77
|
+
|
78
|
+
# The unique name of the cluster. Value in the form
|
79
|
+
# `projects/<project_id>/instances/<instance_id>/clusters/<cluster_id>`.
|
80
|
+
#
|
81
|
+
# @return [String]
|
82
|
+
def path
|
83
|
+
@grpc.name
|
84
|
+
end
|
85
|
+
|
86
|
+
# The current instance state.
|
87
|
+
# Possible values are
|
88
|
+
# `:CREATING`, `:READY`, `:STATE_NOT_KNOWN`, `:RESIZING`, `:DISABLED`.
|
89
|
+
#
|
90
|
+
# @return [Symbol]
|
91
|
+
def state
|
92
|
+
@grpc.state
|
93
|
+
end
|
94
|
+
|
95
|
+
# The cluster has been successfully created and is ready to serve requests.
|
96
|
+
#
|
97
|
+
# @return [Boolean]
|
98
|
+
def ready?
|
99
|
+
state == :READY
|
100
|
+
end
|
101
|
+
|
102
|
+
# The instance is currently being created, and may be destroyed if the
|
103
|
+
# creation process encounters an error.
|
104
|
+
#
|
105
|
+
# @return [Boolean]
|
106
|
+
def creating?
|
107
|
+
state == :CREATING
|
108
|
+
end
|
109
|
+
|
110
|
+
# The cluster is currently being resized, and may revert to its previous
|
111
|
+
# node count if the process encounters an error.
|
112
|
+
# A cluster is still capable of serving requests while being resized,
|
113
|
+
# but may exhibit performance as if its number of allocated nodes is
|
114
|
+
# between the starting and requested states.
|
115
|
+
#
|
116
|
+
# @return [Boolean]
|
117
|
+
def resizing?
|
118
|
+
state == :RESIZING
|
119
|
+
end
|
120
|
+
|
121
|
+
# The cluster has no backing nodes. The data (tables) still
|
122
|
+
# exist, but no operations can be performed on the cluster.
|
123
|
+
#
|
124
|
+
# @return [Boolean]
|
125
|
+
def disabled?
|
126
|
+
state == :DISABLED
|
127
|
+
end
|
128
|
+
|
129
|
+
# The number of nodes allocated to this cluster.
|
130
|
+
#
|
131
|
+
# @return [Integer]
|
132
|
+
def nodes
|
133
|
+
@grpc.serve_nodes
|
134
|
+
end
|
135
|
+
|
136
|
+
# The number of nodes allocated to this cluster. More nodes enable higher
|
137
|
+
# throughput and more consistent performance.
|
138
|
+
#
|
139
|
+
# @param serve_nodes [Integer] Number of nodes
|
140
|
+
def nodes= serve_nodes
|
141
|
+
@grpc.serve_nodes = serve_nodes
|
142
|
+
end
|
143
|
+
|
144
|
+
# The type of storage used by this cluster to serve its
|
145
|
+
# parent instance's tables, unless explicitly overridden.
|
146
|
+
# Valid values are `:SSD`(Flash (SSD) storage should be used),
|
147
|
+
# `:HDD`(Magnetic drive (HDD) storage should be used)
|
148
|
+
#
|
149
|
+
# @return [Symbol]
|
150
|
+
def storage_type
|
151
|
+
@grpc.default_storage_type
|
152
|
+
end
|
153
|
+
|
154
|
+
# Cluster location.
|
155
|
+
# i.e "us-east-1b"
|
156
|
+
#
|
157
|
+
# @return [String]
|
158
|
+
def location
|
159
|
+
@grpc.location.split("/")[3]
|
160
|
+
end
|
161
|
+
|
162
|
+
# Cluster location path in form of
|
163
|
+
# `projects/<project_id>/locations/<zone>`
|
164
|
+
#
|
165
|
+
# @return [String]
|
166
|
+
def location_path
|
167
|
+
@grpc.location
|
168
|
+
end
|
169
|
+
|
170
|
+
# Update cluster.
|
171
|
+
#
|
172
|
+
# Updatable fields are no of nodes.
|
173
|
+
#
|
174
|
+
# @return [Google::Cloud::Bigtable::Cluster::Job]
|
175
|
+
# The job representing the long-running, asynchronous processing of
|
176
|
+
# an update cluster operation.
|
177
|
+
#
|
178
|
+
# @example
|
179
|
+
# require "google/cloud/bigtable"
|
180
|
+
#
|
181
|
+
# bigtable = Google::Cloud::Bigtable.new
|
182
|
+
#
|
183
|
+
# instance = bigtable.instance("my-instance")
|
184
|
+
# cluster = instance.cluster("my-cluster")
|
185
|
+
# cluster.nodes = 3
|
186
|
+
# job = cluster.save
|
187
|
+
#
|
188
|
+
# job.done? #=> false
|
189
|
+
#
|
190
|
+
# # To block until the operation completes.
|
191
|
+
# job.wait_until_done!
|
192
|
+
# job.done? #=> true
|
193
|
+
#
|
194
|
+
# if job.error?
|
195
|
+
# status = job.error
|
196
|
+
# else
|
197
|
+
# cluster = job.cluster
|
198
|
+
# end
|
199
|
+
#
|
200
|
+
def save
|
201
|
+
ensure_service!
|
202
|
+
grpc = service.update_cluster(
|
203
|
+
instance_id,
|
204
|
+
cluster_id,
|
205
|
+
location_path,
|
206
|
+
nodes
|
207
|
+
)
|
208
|
+
Cluster::Job.from_grpc(grpc, service)
|
209
|
+
end
|
210
|
+
alias update save
|
211
|
+
|
212
|
+
# Reload cluster information.
|
213
|
+
#
|
214
|
+
# @return [Google::Cloud::Bigtable::Cluster]
|
215
|
+
|
216
|
+
def reload!
|
217
|
+
@grpc = service.get_cluster(instance_id, cluster_id)
|
218
|
+
self
|
219
|
+
end
|
220
|
+
|
221
|
+
# Permanently deletes the cluster
|
222
|
+
#
|
223
|
+
# @return [Boolean] Returns `true` if the cluster was deleted.
|
224
|
+
#
|
225
|
+
# @example
|
226
|
+
# require "google/cloud/bigtable"
|
227
|
+
#
|
228
|
+
# bigtable = Google::Cloud::Bigtable.new
|
229
|
+
#
|
230
|
+
# instance = bigtable.instance("my-instance")
|
231
|
+
# cluster = instance.cluster("my-cluster")
|
232
|
+
# cluster.delete
|
233
|
+
#
|
234
|
+
def delete
|
235
|
+
ensure_service!
|
236
|
+
service.delete_cluster(instance_id, cluster_id)
|
237
|
+
true
|
238
|
+
end
|
239
|
+
|
240
|
+
# @private
|
241
|
+
#
|
242
|
+
# Creates a new Cluster instance from a
|
243
|
+
# Google::Bigtable::Admin::V2::Cluster.
|
244
|
+
#
|
245
|
+
# @param grpc [Google::Bigtable::Admin::V2::Cluster]
|
246
|
+
# @param service [Google::Cloud::Bigtable::Service]
|
247
|
+
# @return [Google::Cloud::Bigtable::Cluster]
|
248
|
+
def self.from_grpc grpc, service
|
249
|
+
new(grpc, service)
|
250
|
+
end
|
251
|
+
|
252
|
+
protected
|
253
|
+
|
254
|
+
# @private
|
255
|
+
#
|
256
|
+
# Raise an error unless an active connection to the service is
|
257
|
+
# available.
|
258
|
+
def ensure_service!
|
259
|
+
raise "Must have active connection to service" unless service
|
260
|
+
end
|
261
|
+
end
|
262
|
+
end
|
263
|
+
end
|
264
|
+
end
|