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,82 @@
|
|
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
|
+
module Google
|
19
|
+
module Cloud
|
20
|
+
module Bigtable
|
21
|
+
# # SampleRowKey
|
22
|
+
#
|
23
|
+
# Sample row key with byte offset.
|
24
|
+
#
|
25
|
+
# NOTE:
|
26
|
+
# * row_key : Sorted streamed sequence of sample row keys in the table.
|
27
|
+
# The table might have contents before the first row key in the list and after
|
28
|
+
# the last one, but a key containing the empty string indicates
|
29
|
+
# "end of table" and will be the last response given, if present.
|
30
|
+
# Note: that row keys in this list may not have ever been written to or read
|
31
|
+
# from, and users should therefore not make any assumptions about the row key
|
32
|
+
# structure that are specific to their use case.
|
33
|
+
|
34
|
+
# * offset_bytes : Approximate total storage space used by all rows in the table which precede
|
35
|
+
# `row_key`. Buffering the contents of all rows between two subsequent
|
36
|
+
# samples would require space roughly equal to the difference in their
|
37
|
+
# `offset_bytes` fields.
|
38
|
+
#
|
39
|
+
# @example
|
40
|
+
# require "google/cloud"
|
41
|
+
#
|
42
|
+
# bigtable = Google::Cloud::Bigtable.new
|
43
|
+
#
|
44
|
+
# table = bigtable.table("my-instance", "my-table")
|
45
|
+
#
|
46
|
+
# table.sample_row_keys.each do |r|
|
47
|
+
# p r
|
48
|
+
# end
|
49
|
+
#
|
50
|
+
class SampleRowKey
|
51
|
+
# @return [String] Sample row key.
|
52
|
+
attr_reader :key
|
53
|
+
|
54
|
+
# @return [Integer] Row offset in bytes.
|
55
|
+
attr_reader :offset
|
56
|
+
|
57
|
+
# @private
|
58
|
+
#
|
59
|
+
# Create SampleRowKey instance.
|
60
|
+
#
|
61
|
+
# @param key [String]
|
62
|
+
# @param offset [Integer] Row offset in bytes.
|
63
|
+
#
|
64
|
+
def initialize key, offset
|
65
|
+
@key = key
|
66
|
+
@offset = offset
|
67
|
+
end
|
68
|
+
|
69
|
+
# @private
|
70
|
+
#
|
71
|
+
# Creates a new SampleRowKey instance from a
|
72
|
+
# Google::Bigtable::V2::SampleRowKey.
|
73
|
+
# @param grpc [Google::Bigtable::V2::SampleRowKeysResponse]
|
74
|
+
# @return [Google::Cloud::Bigtable::SampleRowKey]
|
75
|
+
#
|
76
|
+
def self.from_grpc grpc
|
77
|
+
new(grpc.row_key, grpc.offset_bytes)
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
@@ -0,0 +1,817 @@
|
|
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/version"
|
19
|
+
require "google/cloud/bigtable/errors"
|
20
|
+
require "google/cloud/bigtable/credentials"
|
21
|
+
require "google/cloud/bigtable/admin/v2/bigtable_instance_admin_client"
|
22
|
+
require "google/cloud/bigtable/admin/v2/bigtable_table_admin_client"
|
23
|
+
require "google/cloud/bigtable/v2/bigtable_client"
|
24
|
+
|
25
|
+
module Google
|
26
|
+
module Cloud
|
27
|
+
module Bigtable
|
28
|
+
# @private
|
29
|
+
# Represents the gRPC Bigtable service, including all the API methods.
|
30
|
+
class Service
|
31
|
+
# @private
|
32
|
+
attr_accessor :project_id, :credentials, :timeout, :client_config
|
33
|
+
|
34
|
+
# @private
|
35
|
+
# Creates a new Service instance.
|
36
|
+
#
|
37
|
+
# @param project_id [String] Project identifier
|
38
|
+
# @param credentials [Google::Auth::Credentials, String, Hash, GRPC::Core::Channel, GRPC::Core::ChannelCredentials, Proc]
|
39
|
+
# Provides the means for authenticating requests made by the client. This parameter can
|
40
|
+
# be many types.
|
41
|
+
# A `Google::Auth::Credentials` uses a the properties of its represented keyfile for
|
42
|
+
# authenticating requests made by this client.
|
43
|
+
# A `String` will be treated as the path to the keyfile to be used for the construction of
|
44
|
+
# credentials for this client.
|
45
|
+
# A `Hash` will be treated as the contents of a keyfile to be used for the construction of
|
46
|
+
# credentials for this client.
|
47
|
+
# A `GRPC::Core::Channel` will be used to make calls through.
|
48
|
+
# A `GRPC::Core::ChannelCredentials` for the setting up the RPC client. The channel credentials
|
49
|
+
# should already be composed with a `GRPC::Core::CallCredentials` object.
|
50
|
+
# A `Proc` will be used as an updater_proc for the Grpc channel. The proc transforms the
|
51
|
+
# metadata for requests, generally, to give OAuth credentials.
|
52
|
+
# @param timeout [Integer]
|
53
|
+
# The default timeout, in seconds, for calls made through this client.
|
54
|
+
# @param client_config [Hash]
|
55
|
+
# A Hash for call options for each method.
|
56
|
+
# See Google::Gax#construct_settings for the structure of
|
57
|
+
# this data. Falls back to the default config if not specified
|
58
|
+
# or the specified config is missing data points.
|
59
|
+
|
60
|
+
def initialize project_id, credentials, timeout: nil, client_config: nil
|
61
|
+
@project_id = project_id
|
62
|
+
@credentials = credentials
|
63
|
+
@timeout = timeout
|
64
|
+
@client_config = client_config || {}
|
65
|
+
end
|
66
|
+
|
67
|
+
# Create or return existing instance of instance admin client.
|
68
|
+
#
|
69
|
+
# @return [Google::Cloud::Bigtable::Admin::V2::BigtableInstanceAdminClient]
|
70
|
+
|
71
|
+
def instances
|
72
|
+
@instances ||= \
|
73
|
+
Admin::V2::BigtableInstanceAdminClient.new(
|
74
|
+
credentials: credentials,
|
75
|
+
timeout: timeout,
|
76
|
+
client_config: client_config,
|
77
|
+
lib_name: "gccl",
|
78
|
+
lib_version: Google::Cloud::Bigtable::VERSION
|
79
|
+
)
|
80
|
+
end
|
81
|
+
|
82
|
+
# Create or return existing instance of table admin client.
|
83
|
+
#
|
84
|
+
# @return [Google::Cloud::Bigtable::Admin::V2::BigtableTableAdminClient]
|
85
|
+
|
86
|
+
def tables
|
87
|
+
@tables ||= \
|
88
|
+
Admin::V2::BigtableTableAdminClient.new(
|
89
|
+
credentials: credentials,
|
90
|
+
timeout: timeout,
|
91
|
+
client_config: client_config,
|
92
|
+
lib_name: "gccl",
|
93
|
+
lib_version: Google::Cloud::Bigtable::VERSION
|
94
|
+
)
|
95
|
+
end
|
96
|
+
|
97
|
+
# Create instance of data client.
|
98
|
+
#
|
99
|
+
# @return [Google::Cloud::Bigtable::V2::BigtableClient]
|
100
|
+
|
101
|
+
def client
|
102
|
+
@client ||= \
|
103
|
+
V2::BigtableClient.new(
|
104
|
+
credentials: credentials,
|
105
|
+
timeout: timeout,
|
106
|
+
client_config: client_config,
|
107
|
+
lib_name: "gccl",
|
108
|
+
lib_version: Google::Cloud::Bigtable::VERSION
|
109
|
+
)
|
110
|
+
end
|
111
|
+
|
112
|
+
# Create an instance within a project.
|
113
|
+
#
|
114
|
+
# @param instance_id [String]
|
115
|
+
# The ID to be used when referring to the new instance within its project.
|
116
|
+
# e.g., +myinstance+
|
117
|
+
# @param instance [Google::Bigtable::Admin::V2::Instance | Hash]
|
118
|
+
# @param clusters [Hash{String => Google::Bigtable::Admin::V2::Cluster | Hash}]
|
119
|
+
# The clusters to be created within the instance, mapped by desired
|
120
|
+
# cluster ID, e.g., just +mycluster+ rather than
|
121
|
+
# +projects/myproject/instances/myinstance/clusters/mycluster+.
|
122
|
+
# Fields marked +OutputOnly+ must be left blank.
|
123
|
+
# Currently exactly one cluster must be specified.
|
124
|
+
# A hash of the same form as `Google::Bigtable::Admin::V2::Cluster`
|
125
|
+
# can also be provided.
|
126
|
+
# @return [Google::Gax::Operation]
|
127
|
+
|
128
|
+
def create_instance \
|
129
|
+
instance_id,
|
130
|
+
instance,
|
131
|
+
clusters
|
132
|
+
execute do
|
133
|
+
instances.create_instance(
|
134
|
+
project_path,
|
135
|
+
instance_id,
|
136
|
+
instance,
|
137
|
+
clusters
|
138
|
+
)
|
139
|
+
end
|
140
|
+
end
|
141
|
+
|
142
|
+
# Lists information about instances in a project.
|
143
|
+
#
|
144
|
+
# @param token [String]
|
145
|
+
# The value of +next_page_token+ returned by a previous call.
|
146
|
+
# @return [Google::Bigtable::Admin::V2::ListInstancesResponse]
|
147
|
+
|
148
|
+
def list_instances token: nil
|
149
|
+
execute do
|
150
|
+
instances.list_instances(
|
151
|
+
project_path,
|
152
|
+
page_token: token
|
153
|
+
)
|
154
|
+
end
|
155
|
+
end
|
156
|
+
|
157
|
+
# Gets information about an instance.
|
158
|
+
#
|
159
|
+
# @param instance_id [String]
|
160
|
+
# The unique ID of the requested instance.
|
161
|
+
# @return [Google::Bigtable::Admin::V2::Instance]
|
162
|
+
|
163
|
+
def get_instance instance_id
|
164
|
+
execute do
|
165
|
+
instances.get_instance(
|
166
|
+
instance_path(instance_id)
|
167
|
+
)
|
168
|
+
end
|
169
|
+
end
|
170
|
+
|
171
|
+
# Partially updates an instance within a project.
|
172
|
+
#
|
173
|
+
# @param instance [Google::Bigtable::Admin::V2::Instance | Hash]
|
174
|
+
# The Instance which will (partially) replace the current value.
|
175
|
+
# A hash of the same form as `Google::Bigtable::Admin::V2::Instance`
|
176
|
+
# can also be provided.
|
177
|
+
# @param update_mask [Google::Protobuf::FieldMask | Hash]
|
178
|
+
# The subset of Instance fields which should be replaced.
|
179
|
+
# Must be explicitly set.
|
180
|
+
# A hash of the same form as `Google::Protobuf::FieldMask`
|
181
|
+
# can also be provided.
|
182
|
+
# @return [Google::Gax::Operation]
|
183
|
+
|
184
|
+
def partial_update_instance instance, update_mask
|
185
|
+
execute do
|
186
|
+
instances.partial_update_instance(instance, update_mask)
|
187
|
+
end
|
188
|
+
end
|
189
|
+
|
190
|
+
# Delete an instance from a project.
|
191
|
+
#
|
192
|
+
# @param instance_id [String]
|
193
|
+
# The unique Id of the instance to be deleted.
|
194
|
+
|
195
|
+
def delete_instance instance_id
|
196
|
+
execute do
|
197
|
+
instances.delete_instance(
|
198
|
+
instance_path(instance_id)
|
199
|
+
)
|
200
|
+
end
|
201
|
+
end
|
202
|
+
|
203
|
+
# Create a cluster within an instance.
|
204
|
+
#
|
205
|
+
# @param instance_id [String]
|
206
|
+
# The unique name of the instance in which to create the new cluster
|
207
|
+
# @param cluster_id [String]
|
208
|
+
# The ID to be used when referring to the new cluster within its instance,
|
209
|
+
# e.g., just +mycluster+
|
210
|
+
# @param cluster [Google::Bigtable::Admin::V2::Cluster | Hash]
|
211
|
+
# The cluster to be created.
|
212
|
+
# Fields marked +OutputOnly+ must be left blank.
|
213
|
+
# A hash of the same form as `Google::Bigtable::Admin::V2::Cluster`
|
214
|
+
# can also be provided.
|
215
|
+
# @return [Google::Gax::Operation]
|
216
|
+
|
217
|
+
def create_cluster instance_id, cluster_id, cluster
|
218
|
+
unless cluster.location == ""
|
219
|
+
cluster.location = location_path(cluster.location)
|
220
|
+
end
|
221
|
+
|
222
|
+
execute do
|
223
|
+
instances.create_cluster(
|
224
|
+
instance_path(instance_id),
|
225
|
+
cluster_id,
|
226
|
+
cluster
|
227
|
+
)
|
228
|
+
end
|
229
|
+
end
|
230
|
+
|
231
|
+
# Lists information about clusters in an instance.
|
232
|
+
#
|
233
|
+
# @param instance_id [String]
|
234
|
+
# The unique name of the instance for which a list of clusters is requested.
|
235
|
+
# @param token [String]
|
236
|
+
# The value of +next_page_token+ returned by a previous call.
|
237
|
+
# @return [Google::Bigtable::Admin::V2::ListClustersResponse]
|
238
|
+
|
239
|
+
def list_clusters instance_id, token: nil
|
240
|
+
execute do
|
241
|
+
instances.list_clusters(
|
242
|
+
instance_path(instance_id),
|
243
|
+
page_token: token
|
244
|
+
)
|
245
|
+
end
|
246
|
+
end
|
247
|
+
|
248
|
+
# Gets information about a cluster.
|
249
|
+
#
|
250
|
+
# @param instance_id [String]
|
251
|
+
# The unique Id of the instance.
|
252
|
+
# @param cluster_id [String]
|
253
|
+
# The unique Id of the requested cluster.
|
254
|
+
# @return [Google::Bigtable::Admin::V2::Cluster]
|
255
|
+
|
256
|
+
def get_cluster instance_id, cluster_id
|
257
|
+
execute do
|
258
|
+
instances.get_cluster(
|
259
|
+
cluster_path(instance_id, cluster_id)
|
260
|
+
)
|
261
|
+
end
|
262
|
+
end
|
263
|
+
|
264
|
+
# Updates a cluster within an instance.
|
265
|
+
#
|
266
|
+
# @param instance_id [String]
|
267
|
+
# The unique Id of the instance.
|
268
|
+
# @param cluster_id [String]
|
269
|
+
# The unique Id of the cluster.
|
270
|
+
# @param location [String]
|
271
|
+
# The location where this cluster's nodes and storage reside. For best
|
272
|
+
# performance, clients should be located as close as possible to this
|
273
|
+
# cluster. Currently only zones are supported, so values should be of the
|
274
|
+
# form +projects/<project>/locations/<zone>+.
|
275
|
+
# @param serve_nodes [Integer]
|
276
|
+
# The number of nodes allocated to this cluster. More nodes enable higher
|
277
|
+
# throughput and more consistent performance.
|
278
|
+
# @return [Google::Gax::Operation]
|
279
|
+
|
280
|
+
def update_cluster instance_id, cluster_id, location, serve_nodes
|
281
|
+
execute do
|
282
|
+
instances.update_cluster(
|
283
|
+
cluster_path(instance_id, cluster_id),
|
284
|
+
location,
|
285
|
+
serve_nodes
|
286
|
+
)
|
287
|
+
end
|
288
|
+
end
|
289
|
+
|
290
|
+
# Deletes a cluster from an instance.
|
291
|
+
#
|
292
|
+
# @param instance_id [String]
|
293
|
+
# The unique Id of the instance in which cluster present.
|
294
|
+
# @param cluster_id [String]
|
295
|
+
# The unique Id of the cluster to be deleted.
|
296
|
+
|
297
|
+
def delete_cluster instance_id, cluster_id
|
298
|
+
execute do
|
299
|
+
instances.delete_cluster(
|
300
|
+
cluster_path(instance_id, cluster_id)
|
301
|
+
)
|
302
|
+
end
|
303
|
+
end
|
304
|
+
|
305
|
+
# Creates a new table in the specified instance.
|
306
|
+
# The table can be created with a full set of initial column families,
|
307
|
+
# specified in the request.
|
308
|
+
#
|
309
|
+
# @param instance_id [String]
|
310
|
+
# The unique Id of the instance in which to create the table.
|
311
|
+
# @param table_id [String]
|
312
|
+
# The name by which the new table should be referred to within the parent
|
313
|
+
# instance, e.g., +foobar+
|
314
|
+
# @param table [Google::Bigtable::Admin::V2::Table | Hash]
|
315
|
+
# The Table to create.
|
316
|
+
# A hash of the same form as `Google::Bigtable::Admin::V2::Table`
|
317
|
+
# can also be provided.
|
318
|
+
# @param initial_splits [Array<Google::Bigtable::Admin::V2::CreateTableRequest::Split | Hash>]
|
319
|
+
# The optional list of row keys that will be used to initially split the
|
320
|
+
# table into several tablets (tablets are similar to HBase regions).
|
321
|
+
# Given two split keys, +s1+ and +s2+, three tablets will be created,
|
322
|
+
# spanning the key ranges: +[, s1), [s1, s2), [s2, )+.
|
323
|
+
#
|
324
|
+
# Example:
|
325
|
+
#
|
326
|
+
# * Row keys := +["a", "apple", "custom", "customer_1", "customer_2",+
|
327
|
+
# +"other", "zz"]+
|
328
|
+
# * initial_split_keys := +["apple", "customer_1", "customer_2", "other"]+
|
329
|
+
# * Key assignment:
|
330
|
+
# * Tablet 1 +[, apple) => {"a"}.+
|
331
|
+
# * Tablet 2 +[apple, customer_1) => {"apple", "custom"}.+
|
332
|
+
# * Tablet 3 +[customer_1, customer_2) => {"customer_1"}.+
|
333
|
+
# * Tablet 4 +[customer_2, other) => {"customer_2"}.+
|
334
|
+
# * Tablet 5 +[other, ) => {"other", "zz"}.+
|
335
|
+
# A hash of the same form as `Google::Bigtable::Admin::V2::CreateTableRequest::Split`
|
336
|
+
# can also be provided.
|
337
|
+
# @return [Google::Bigtable::Admin::V2::Table]
|
338
|
+
|
339
|
+
def create_table \
|
340
|
+
instance_id,
|
341
|
+
table_id,
|
342
|
+
table,
|
343
|
+
initial_splits: nil
|
344
|
+
if initial_splits
|
345
|
+
initial_splits = initial_splits.map { |key| { key: key } }
|
346
|
+
end
|
347
|
+
|
348
|
+
execute do
|
349
|
+
tables.create_table(
|
350
|
+
instance_path(instance_id),
|
351
|
+
table_id,
|
352
|
+
table,
|
353
|
+
initial_splits: initial_splits
|
354
|
+
)
|
355
|
+
end
|
356
|
+
end
|
357
|
+
|
358
|
+
# Lists all tables served from a specified instance.
|
359
|
+
#
|
360
|
+
# @param instance_id [String]
|
361
|
+
# The unique Id of the instance for which tables should be listed.
|
362
|
+
# @param view [Google::Bigtable::Admin::V2::Table::View]
|
363
|
+
# The view to be applied to the returned tables' fields.
|
364
|
+
# Defaults to +NAME_ONLY+ if unspecified; no others are currently supported.
|
365
|
+
# @return [Google::Gax::PagedEnumerable<Google::Bigtable::Admin::V2::Table>]
|
366
|
+
# An enumerable of Google::Bigtable::Admin::V2::Table instances.
|
367
|
+
# See Google::Gax::PagedEnumerable documentation for other
|
368
|
+
# operations such as per-page iteration or access to the response
|
369
|
+
|
370
|
+
def list_tables instance_id, view: nil
|
371
|
+
execute do
|
372
|
+
tables.list_tables(
|
373
|
+
instance_path(instance_id),
|
374
|
+
view: view
|
375
|
+
)
|
376
|
+
end
|
377
|
+
end
|
378
|
+
|
379
|
+
# Gets metadata information about the specified table.
|
380
|
+
#
|
381
|
+
# @param instance_id [String]
|
382
|
+
# The unique Id of the instance in which table is exists.
|
383
|
+
# @param table_id [String]
|
384
|
+
# The unique Id of the requested table.
|
385
|
+
# @param view [Google::Bigtable::Admin::V2::Table::View]
|
386
|
+
# The view to be applied to the returned table's fields.
|
387
|
+
# Defaults to +SCHEMA_VIEW+ if unspecified.
|
388
|
+
# @return [Google::Bigtable::Admin::V2::Table]
|
389
|
+
|
390
|
+
def get_table instance_id, table_id, view: nil
|
391
|
+
execute do
|
392
|
+
tables.get_table(
|
393
|
+
table_path(instance_id, table_id),
|
394
|
+
view: view
|
395
|
+
)
|
396
|
+
end
|
397
|
+
end
|
398
|
+
|
399
|
+
# Permanently deletes a specified table and all of its data.
|
400
|
+
#
|
401
|
+
# @param instance_id [String]
|
402
|
+
# The unique Id of the instance in which table is exists.
|
403
|
+
# @param table_id [String]
|
404
|
+
# The unique Id of the table to be deleted.
|
405
|
+
|
406
|
+
def delete_table instance_id, table_id
|
407
|
+
execute do
|
408
|
+
tables.delete_table(
|
409
|
+
table_path(instance_id, table_id)
|
410
|
+
)
|
411
|
+
end
|
412
|
+
end
|
413
|
+
|
414
|
+
# Performs a series of column family modifications on the specified table.
|
415
|
+
# Either all or none of the modifications will occur before this method
|
416
|
+
# returns, but data requests received prior to that point may see a table
|
417
|
+
# where only some modifications have taken effect.
|
418
|
+
#
|
419
|
+
# @param instance_id [String]
|
420
|
+
# The unique Id of the instance in which table is exists.
|
421
|
+
# @param table_id [String]
|
422
|
+
# The unique Id of the table whose families should be modified.
|
423
|
+
# @param modifications [Array<Google::Bigtable::Admin::V2::ModifyColumnFamiliesRequest::Modification | Hash>]
|
424
|
+
# Modifications to be atomically applied to the specified table's families.
|
425
|
+
# Entries are applied in order, meaning that earlier modifications can be
|
426
|
+
# masked by later ones (in the case of repeated updates to the same family,
|
427
|
+
# for example).
|
428
|
+
# A hash of the same form as `Google::Bigtable::Admin::V2::ModifyColumnFamiliesRequest::Modification`
|
429
|
+
# can also be provided.
|
430
|
+
# @return [Google::Bigtable::Admin::V2::Table]
|
431
|
+
|
432
|
+
def modify_column_families instance_id, table_id, modifications
|
433
|
+
execute do
|
434
|
+
tables.modify_column_families(
|
435
|
+
table_path(instance_id, table_id),
|
436
|
+
modifications
|
437
|
+
)
|
438
|
+
end
|
439
|
+
end
|
440
|
+
|
441
|
+
# Generates a consistency token for a Table, which can be used in
|
442
|
+
# CheckConsistency to check whether mutations to the table that finished
|
443
|
+
# before this call started have been replicated. The tokens will be available
|
444
|
+
# for 90 days.
|
445
|
+
#
|
446
|
+
# @param instance_id [String]
|
447
|
+
# The unique Id of the instance in which table is exists.
|
448
|
+
# @param table_id [String]
|
449
|
+
# The unique Id of the Table for which to create a consistency token.
|
450
|
+
# @return [Google::Bigtable::Admin::V2::GenerateConsistencyTokenResponse]
|
451
|
+
|
452
|
+
def generate_consistency_token instance_id, table_id
|
453
|
+
execute do
|
454
|
+
tables.generate_consistency_token(
|
455
|
+
table_path(instance_id, table_id)
|
456
|
+
)
|
457
|
+
end
|
458
|
+
end
|
459
|
+
|
460
|
+
# Checks replication consistency based on a consistency token, that is, if
|
461
|
+
# replication has caught up based on the conditions specified in the token
|
462
|
+
# and the check request.
|
463
|
+
#
|
464
|
+
# @param instance_id [String]
|
465
|
+
# The unique Id of the instance in which table is exists.
|
466
|
+
# @param table_id [String]
|
467
|
+
# The unique Id of the Table for which to check replication consistency.
|
468
|
+
# @param token [String] Consistency token
|
469
|
+
# The token created using GenerateConsistencyToken for the Table.
|
470
|
+
# @return [Google::Bigtable::Admin::V2::CheckConsistencyResponse]
|
471
|
+
|
472
|
+
def check_consistency instance_id, table_id, token
|
473
|
+
execute do
|
474
|
+
tables.check_consistency(
|
475
|
+
table_path(instance_id, table_id),
|
476
|
+
token
|
477
|
+
)
|
478
|
+
end
|
479
|
+
end
|
480
|
+
|
481
|
+
# Permanently drop/delete a row range from a specified table. The request can
|
482
|
+
# specify whether to delete all rows in a table, or only those that match a
|
483
|
+
# particular prefix.
|
484
|
+
#
|
485
|
+
# @param instance_id [String]
|
486
|
+
# The unique Id of the instance in which table is exists.
|
487
|
+
# @param table_id [String]
|
488
|
+
# The unique Id of the table on which to drop a range of rows.
|
489
|
+
# @param row_key_prefix [String]
|
490
|
+
# Delete all rows that start with this row key prefix. Prefix cannot be
|
491
|
+
# zero length.
|
492
|
+
# @param delete_all_data_from_table [true, false]
|
493
|
+
# Delete all rows in the table. Setting this to false is a no-op.
|
494
|
+
# @param timeout [Integer]
|
495
|
+
# Set api call timeout if deadline exceeded exception.
|
496
|
+
|
497
|
+
def drop_row_range \
|
498
|
+
instance_id,
|
499
|
+
table_id,
|
500
|
+
row_key_prefix: nil,
|
501
|
+
delete_all_data_from_table: nil,
|
502
|
+
timeout: nil
|
503
|
+
call_options = nil
|
504
|
+
|
505
|
+
# Pass timeout with larger value if drop operation throw error for
|
506
|
+
# tiemout time.
|
507
|
+
if timeout
|
508
|
+
retry_options = Google::Gax::RetryOptions.new(
|
509
|
+
[],
|
510
|
+
Google::Gax::BackoffSettings.new(0, 0, 0, timeout * 1000, 0, 0, 0)
|
511
|
+
)
|
512
|
+
call_options = Google::Gax::CallOptions.new(
|
513
|
+
retry_options: retry_options
|
514
|
+
)
|
515
|
+
end
|
516
|
+
|
517
|
+
execute do
|
518
|
+
tables.drop_row_range(
|
519
|
+
table_path(instance_id, table_id),
|
520
|
+
row_key_prefix: row_key_prefix,
|
521
|
+
delete_all_data_from_table: delete_all_data_from_table,
|
522
|
+
options: call_options
|
523
|
+
)
|
524
|
+
end
|
525
|
+
end
|
526
|
+
|
527
|
+
# Creates an app profile within an instance.
|
528
|
+
#
|
529
|
+
# @param instance_id [String]
|
530
|
+
# The unique Id of the instance.
|
531
|
+
# @param app_profile_id [String]
|
532
|
+
# The ID to be used when referring to the new app profile within its
|
533
|
+
# instance, e.g., +myprofile+
|
534
|
+
# @param app_profile [Google::Bigtable::Admin::V2::AppProfile | Hash]
|
535
|
+
# The app profile to be created.
|
536
|
+
# Fields marked +OutputOnly+ will be ignored.
|
537
|
+
# A hash of the same form as `Google::Bigtable::Admin::V2::AppProfile`
|
538
|
+
# can also be provided.
|
539
|
+
# @param ignore_warnings [Boolean]
|
540
|
+
# If true, ignore safety checks when creating the app profile.
|
541
|
+
# @return [Google::Bigtable::Admin::V2::AppProfile]
|
542
|
+
|
543
|
+
def create_app_profile \
|
544
|
+
instance_id,
|
545
|
+
app_profile_id,
|
546
|
+
app_profile,
|
547
|
+
ignore_warnings: nil
|
548
|
+
execute do
|
549
|
+
instances.create_app_profile(
|
550
|
+
instance_path(instance_id),
|
551
|
+
app_profile_id,
|
552
|
+
app_profile,
|
553
|
+
ignore_warnings: ignore_warnings
|
554
|
+
)
|
555
|
+
end
|
556
|
+
end
|
557
|
+
|
558
|
+
# Gets information about an app profile.
|
559
|
+
#
|
560
|
+
# @param instance_id [String]
|
561
|
+
# The unique Id of the instance.
|
562
|
+
# @param app_profile_id [String]
|
563
|
+
# The unique Id of the requested app profile.
|
564
|
+
# @return [Google::Bigtable::Admin::V2::AppProfile]
|
565
|
+
|
566
|
+
def get_app_profile instance_id, app_profile_id
|
567
|
+
execute do
|
568
|
+
instances.get_app_profile(
|
569
|
+
app_profile_path(instance_id, app_profile_id)
|
570
|
+
)
|
571
|
+
end
|
572
|
+
end
|
573
|
+
|
574
|
+
# Lists information about app profiles in an instance.
|
575
|
+
#
|
576
|
+
# @param instance_id [String]
|
577
|
+
# The unique Id of the instanc
|
578
|
+
# @return [Google::Gax::PagedEnumerable<Google::Bigtable::Admin::V2::AppProfile>]
|
579
|
+
# An enumerable of Google::Bigtable::Admin::V2::AppProfile instances.
|
580
|
+
# See Google::Gax::PagedEnumerable documentation for other
|
581
|
+
# operations such as per-page iteration or access to the response
|
582
|
+
# object.
|
583
|
+
def list_app_profiles instance_id
|
584
|
+
execute do
|
585
|
+
instances.list_app_profiles(
|
586
|
+
instance_path(instance_id)
|
587
|
+
)
|
588
|
+
end
|
589
|
+
end
|
590
|
+
|
591
|
+
# Updates an app profile within an instance.
|
592
|
+
#
|
593
|
+
# @param app_profile [Google::Bigtable::Admin::V2::AppProfile | Hash]
|
594
|
+
# The app profile which will (partially) replace the current value.
|
595
|
+
# A hash of the same form as `Google::Bigtable::Admin::V2::AppProfile`
|
596
|
+
# can also be provided.
|
597
|
+
# @param update_mask [Google::Protobuf::FieldMask | Hash]
|
598
|
+
# The subset of app profile fields which should be replaced.
|
599
|
+
# If unset, all fields will be replaced.
|
600
|
+
# A hash of the same form as `Google::Protobuf::FieldMask`
|
601
|
+
# can also be provided.
|
602
|
+
# @param ignore_warnings [Boolean]
|
603
|
+
# If true, ignore safety checks when updating the app profile.
|
604
|
+
# @return [Google::Longrunning::Operation]
|
605
|
+
|
606
|
+
def update_app_profile app_profile, update_mask, ignore_warnings: nil
|
607
|
+
execute do
|
608
|
+
instances.update_app_profile(
|
609
|
+
app_profile,
|
610
|
+
update_mask,
|
611
|
+
ignore_warnings: ignore_warnings
|
612
|
+
)
|
613
|
+
end
|
614
|
+
end
|
615
|
+
|
616
|
+
# Deletes an app profile from an instance.
|
617
|
+
#
|
618
|
+
# @param instance_id [String]
|
619
|
+
# The unique Id of the instance.
|
620
|
+
# @param app_profile_id [String]
|
621
|
+
# The unique Id of the app profile to be deleted.
|
622
|
+
# @param ignore_warnings [Boolean]
|
623
|
+
# If true, ignore safety checks when deleting the app profile.
|
624
|
+
|
625
|
+
def delete_app_profile instance_id, app_profile_id, ignore_warnings: nil
|
626
|
+
execute do
|
627
|
+
instances.delete_app_profile(
|
628
|
+
app_profile_path(instance_id, app_profile_id),
|
629
|
+
ignore_warnings
|
630
|
+
)
|
631
|
+
end
|
632
|
+
end
|
633
|
+
|
634
|
+
# Gets the access control policy for an instance resource. Returns an empty
|
635
|
+
# policy if an instance exists but does not have a policy set.
|
636
|
+
#
|
637
|
+
# @param instance_id [String]
|
638
|
+
# The unique Id of the instance for which the policy is being requested.
|
639
|
+
# @return [Google::Iam::V1::Policy]
|
640
|
+
|
641
|
+
def get_instance_policy instance_id
|
642
|
+
execute do
|
643
|
+
instances.get_iam_policy(
|
644
|
+
instance_path(instance_id)
|
645
|
+
)
|
646
|
+
end
|
647
|
+
end
|
648
|
+
|
649
|
+
# Sets the access control policy on an instance resource. Replaces any
|
650
|
+
# existing policy.
|
651
|
+
#
|
652
|
+
# @param instance_id [String]
|
653
|
+
# The unique Id of the instance for which the policy is being updated.
|
654
|
+
# @param policy [Google::Iam::V1::Policy | Hash]
|
655
|
+
# REQUIRED: The complete policy to be applied to the +resource+. The size of
|
656
|
+
# the policy is limited to a few 10s of KB. An empty policy is a
|
657
|
+
# valid policy but certain Cloud Platform services (such as Projects)
|
658
|
+
# might reject them.
|
659
|
+
# A hash of the same form as `Google::Iam::V1::Policy`
|
660
|
+
# can also be provided.
|
661
|
+
# @return [Google::Iam::V1::Policy]
|
662
|
+
|
663
|
+
def set_instance_policy instance_id, policy
|
664
|
+
execute do
|
665
|
+
instances.set_iam_policy(
|
666
|
+
instance_path(instance_id),
|
667
|
+
policy
|
668
|
+
)
|
669
|
+
end
|
670
|
+
end
|
671
|
+
|
672
|
+
# Returns permissions that the caller has on the specified instance resource.
|
673
|
+
#
|
674
|
+
# @param instance_id [String]
|
675
|
+
# The instance Id of instance for which the policy detail is being requested.
|
676
|
+
# @param permissions [Array<String>]
|
677
|
+
# The set of permissions to check for the +resource+. Permissions with
|
678
|
+
# wildcards (such as '*' or 'storage.*') are not allowed. For more
|
679
|
+
# information see
|
680
|
+
# [IAM Overview](https://cloud.google.com/iam/docs/overview#permissions).
|
681
|
+
# @return [Google::Iam::V1::TestIamPermissionsResponse]
|
682
|
+
|
683
|
+
def test_instance_permissions instance_id, permissions
|
684
|
+
execute do
|
685
|
+
instances.test_iam_permissions(
|
686
|
+
instance_path(instance_id),
|
687
|
+
permissions
|
688
|
+
)
|
689
|
+
end
|
690
|
+
end
|
691
|
+
|
692
|
+
# Execute api call and wrap errors to {Google::Cloud::Error}
|
693
|
+
#
|
694
|
+
# @raise [Google::Cloud::Error]
|
695
|
+
|
696
|
+
def execute
|
697
|
+
yield
|
698
|
+
rescue Google::Gax::GaxError => e
|
699
|
+
raise Google::Cloud::Error.from_error(e.cause)
|
700
|
+
rescue GRPC::BadStatus => e
|
701
|
+
raise Google::Cloud::Error.from_error(e)
|
702
|
+
end
|
703
|
+
|
704
|
+
# Create formatted project path
|
705
|
+
#
|
706
|
+
# @return [String]
|
707
|
+
# Formatted project path
|
708
|
+
# +projects/<project>+
|
709
|
+
|
710
|
+
def project_path
|
711
|
+
Admin::V2::BigtableInstanceAdminClient.project_path(project_id)
|
712
|
+
end
|
713
|
+
|
714
|
+
# Create formatted instance path
|
715
|
+
#
|
716
|
+
# @param instance_id [String]
|
717
|
+
# @return [String]
|
718
|
+
# Formatted instance path
|
719
|
+
# +projects/<project>/instances/[a-z][a-z0-9\\-]+[a-z0-9]+.
|
720
|
+
|
721
|
+
def instance_path instance_id
|
722
|
+
Admin::V2::BigtableInstanceAdminClient.instance_path(
|
723
|
+
project_id,
|
724
|
+
instance_id
|
725
|
+
)
|
726
|
+
end
|
727
|
+
|
728
|
+
# Create formatted cluster path
|
729
|
+
#
|
730
|
+
# @param instance_id [String]
|
731
|
+
# @param cluster_id [String]
|
732
|
+
# @return [String]
|
733
|
+
# Formatted cluster path
|
734
|
+
# +projects/<project>/instances/<instance>/clusters/<cluster>+.
|
735
|
+
|
736
|
+
def cluster_path instance_id, cluster_id
|
737
|
+
Admin::V2::BigtableInstanceAdminClient.cluster_path(
|
738
|
+
project_id,
|
739
|
+
instance_id,
|
740
|
+
cluster_id
|
741
|
+
)
|
742
|
+
end
|
743
|
+
|
744
|
+
# Create formatted location path
|
745
|
+
#
|
746
|
+
# @param location [String]
|
747
|
+
# zone name i.e us-east1-b
|
748
|
+
# @return [String]
|
749
|
+
# Formatted location path
|
750
|
+
# +projects/<project_id>/locations/<location>+.
|
751
|
+
|
752
|
+
def location_path location
|
753
|
+
Admin::V2::BigtableInstanceAdminClient.location_path(
|
754
|
+
project_id,
|
755
|
+
location
|
756
|
+
)
|
757
|
+
end
|
758
|
+
|
759
|
+
# Create formatted table path
|
760
|
+
#
|
761
|
+
# @param table_id [String]
|
762
|
+
# @return [String]
|
763
|
+
# Formatted table path
|
764
|
+
# +projects/<project>/instances/<instance>/tables/<table>+
|
765
|
+
|
766
|
+
def table_path instance_id, table_id
|
767
|
+
Admin::V2::BigtableTableAdminClient.table_path(
|
768
|
+
project_id,
|
769
|
+
instance_id,
|
770
|
+
table_id
|
771
|
+
)
|
772
|
+
end
|
773
|
+
|
774
|
+
# Create formatted snapshot path
|
775
|
+
#
|
776
|
+
# @param instance_id [String]
|
777
|
+
# @param cluster_id [String]
|
778
|
+
# @param snapshot_id [String]
|
779
|
+
# @return [String]
|
780
|
+
# Formatted snapshot path
|
781
|
+
# +projects/<project>/instances/<instance>/clusters/<cluster>/snapshots/<snapshot>+
|
782
|
+
|
783
|
+
def snapshot_path instance_id, cluster_id, snapshot_id
|
784
|
+
Admin::V2::BigtableTableAdminClient.snapshot_path(
|
785
|
+
project_id,
|
786
|
+
instance_id,
|
787
|
+
cluster_id,
|
788
|
+
snapshot_id
|
789
|
+
)
|
790
|
+
end
|
791
|
+
|
792
|
+
# Create formatted app profile path
|
793
|
+
#
|
794
|
+
# @param instance_id [String]
|
795
|
+
# @param app_profile_id [String]
|
796
|
+
# @return [String]
|
797
|
+
# Formatted snapshot path
|
798
|
+
# +projects/<project>/instances/<instance>/appProfiles/<app_profile>+
|
799
|
+
|
800
|
+
def app_profile_path instance_id, app_profile_id
|
801
|
+
Admin::V2::BigtableInstanceAdminClient.app_profile_path(
|
802
|
+
project_id,
|
803
|
+
instance_id,
|
804
|
+
app_profile_id
|
805
|
+
)
|
806
|
+
end
|
807
|
+
|
808
|
+
# Inspect service object
|
809
|
+
# @return [String]
|
810
|
+
|
811
|
+
def inspect
|
812
|
+
"#{self.class}(#{@project_id})"
|
813
|
+
end
|
814
|
+
end
|
815
|
+
end
|
816
|
+
end
|
817
|
+
end
|