google-cloud-bigtable 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +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,113 @@
|
|
|
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/rpc/code_pb"
|
|
19
|
+
require "google/cloud/bigtable/mutation_entry"
|
|
20
|
+
|
|
21
|
+
module Google
|
|
22
|
+
module Cloud
|
|
23
|
+
module Bigtable
|
|
24
|
+
# @private
|
|
25
|
+
# # RowsMutator
|
|
26
|
+
#
|
|
27
|
+
# Retryable mutate rows helper
|
|
28
|
+
#
|
|
29
|
+
class RowsMutator
|
|
30
|
+
# @private
|
|
31
|
+
# Retryable status codes
|
|
32
|
+
RETRYABLE_CODES = {
|
|
33
|
+
Google::Rpc::Code::DEADLINE_EXCEEDED => true,
|
|
34
|
+
Google::Rpc::Code::ABORTED => true,
|
|
35
|
+
Google::Rpc::Code::UNAVAILABLE => true
|
|
36
|
+
}.freeze
|
|
37
|
+
|
|
38
|
+
# @private
|
|
39
|
+
RETRY_LIMIT = 3
|
|
40
|
+
|
|
41
|
+
# @private
|
|
42
|
+
#
|
|
43
|
+
# Creates a mutate rows instance.
|
|
44
|
+
#
|
|
45
|
+
# @param table [Google::Cloud::Bigtable::TableDataOperations]
|
|
46
|
+
# @param entries [Array<Google::Cloud::Bigtable::MutationEntry>]
|
|
47
|
+
#
|
|
48
|
+
def initialize table, entries
|
|
49
|
+
@table = table
|
|
50
|
+
@entries = entries
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
##
|
|
54
|
+
# Applies mutations.
|
|
55
|
+
#
|
|
56
|
+
# @return [Array<Google::Bigtable::V2::MutateRowsResponse::Entry>]
|
|
57
|
+
#
|
|
58
|
+
def apply_mutations
|
|
59
|
+
@req_entries = @entries.map(&:to_grpc)
|
|
60
|
+
statuses = mutate_rows @req_entries
|
|
61
|
+
|
|
62
|
+
# Collects retryable mutations indices.
|
|
63
|
+
indices = statuses.each_with_object [] do |e, r|
|
|
64
|
+
r << e.index if @entries[e.index].retryable? && RETRYABLE_CODES[e.status.code]
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
return statuses if indices.empty?
|
|
68
|
+
|
|
69
|
+
(RETRY_LIMIT - 1).times do
|
|
70
|
+
break if indices.empty?
|
|
71
|
+
indices = retry_entries statuses, indices
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
statuses
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
private
|
|
78
|
+
|
|
79
|
+
##
|
|
80
|
+
# Mutates rows.
|
|
81
|
+
#
|
|
82
|
+
# @param entries [Array<Google::Cloud::Bigtable::MutationEntry>]
|
|
83
|
+
# @return [Array<Google::Bigtable::V2::MutateRowsResponse::Entry>]
|
|
84
|
+
#
|
|
85
|
+
def mutate_rows entries
|
|
86
|
+
response = @table.service.mutate_rows @table.path, entries, app_profile_id: @table.app_profile_id
|
|
87
|
+
response.each_with_object [] do |res, statuses|
|
|
88
|
+
statuses.concat res.entries
|
|
89
|
+
end
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
##
|
|
93
|
+
# Collects failed entries, retries mutation, and updates status.
|
|
94
|
+
#
|
|
95
|
+
# @param statuses [Array<Google::Bigtable::V2::MutateRowsResponse::Entry>]
|
|
96
|
+
# @param indices [Array<Integer>]
|
|
97
|
+
# Retry entries position mapping list
|
|
98
|
+
# @return [Array<Integer>]
|
|
99
|
+
# New list of failed entries positions
|
|
100
|
+
#
|
|
101
|
+
def retry_entries statuses, indices
|
|
102
|
+
entries = indices.map { |i| @req_entries[i] }
|
|
103
|
+
retry_statuses = mutate_rows entries
|
|
104
|
+
|
|
105
|
+
retry_statuses.each_with_object [] do |e, next_indices|
|
|
106
|
+
next_indices << indices[e.index] if RETRYABLE_CODES[e.status.code]
|
|
107
|
+
statuses[indices[e.index]].status = e.status
|
|
108
|
+
end
|
|
109
|
+
end
|
|
110
|
+
end
|
|
111
|
+
end
|
|
112
|
+
end
|
|
113
|
+
end
|
|
@@ -0,0 +1,200 @@
|
|
|
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/chunk_processor"
|
|
19
|
+
|
|
20
|
+
module Google
|
|
21
|
+
module Cloud
|
|
22
|
+
module Bigtable
|
|
23
|
+
# @private
|
|
24
|
+
# # RowsReader
|
|
25
|
+
#
|
|
26
|
+
# Retryable read rows helper
|
|
27
|
+
#
|
|
28
|
+
class RowsReader
|
|
29
|
+
# @private
|
|
30
|
+
# Retryable error list.
|
|
31
|
+
RETRYABLE_ERRORS = [
|
|
32
|
+
GRPC::DeadlineExceeded,
|
|
33
|
+
GRPC::Aborted,
|
|
34
|
+
GRPC::Unavailable,
|
|
35
|
+
GRPC::Core::CallError
|
|
36
|
+
].freeze
|
|
37
|
+
|
|
38
|
+
# @private
|
|
39
|
+
# Default retry limit
|
|
40
|
+
RETRY_LIMIT = 3
|
|
41
|
+
|
|
42
|
+
# @private
|
|
43
|
+
# @return [Integer] Current retry count
|
|
44
|
+
attr_accessor :retry_count
|
|
45
|
+
|
|
46
|
+
# @private
|
|
47
|
+
#
|
|
48
|
+
# Creates a read rows instance.
|
|
49
|
+
#
|
|
50
|
+
# @param table [Google::Cloud::Bigtable::TableDataOperations]
|
|
51
|
+
#
|
|
52
|
+
def initialize table
|
|
53
|
+
@table = table
|
|
54
|
+
@chunk_processor = ChunkProcessor.new
|
|
55
|
+
@rows_count = 0
|
|
56
|
+
@retry_count = 0
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
##
|
|
60
|
+
# Read rows
|
|
61
|
+
#
|
|
62
|
+
# @param rows [Google::Bigtable::V2::RowSet]
|
|
63
|
+
# The row keys and/or ranges to read.
|
|
64
|
+
# If not specified, reads from all rows.
|
|
65
|
+
# Alternatively, provide a hash in the form of `Google::Bigtable::V2::RowSet`.
|
|
66
|
+
# @param filter [Google::Bigtable::V2::RowFilter | Hash]
|
|
67
|
+
# The filter to apply to the contents of the specified row(s). If unset,
|
|
68
|
+
# reads the entirety of each row.
|
|
69
|
+
# A hash in the form of `Google::Bigtable::V2::RowFilter`
|
|
70
|
+
# can also be provided.
|
|
71
|
+
# @param rows_limit [Integer]
|
|
72
|
+
# The read will terminate after committing to N rows' worth of results.
|
|
73
|
+
# The default (zero) is to return all results.
|
|
74
|
+
# @return [:yields: row]
|
|
75
|
+
# Array of row or yield block for each processed row.
|
|
76
|
+
#
|
|
77
|
+
def read rows: nil, filter: nil, rows_limit: nil
|
|
78
|
+
response = @table.service.read_rows(
|
|
79
|
+
@table.instance_id,
|
|
80
|
+
@table.table_id,
|
|
81
|
+
rows: rows,
|
|
82
|
+
filter: filter,
|
|
83
|
+
rows_limit: rows_limit,
|
|
84
|
+
app_profile_id: @table.app_profile_id
|
|
85
|
+
)
|
|
86
|
+
response.each do |res|
|
|
87
|
+
res.chunks.each do |chunk|
|
|
88
|
+
@retry_count = 0
|
|
89
|
+
row = @chunk_processor.process chunk
|
|
90
|
+
next if row.nil?
|
|
91
|
+
yield row
|
|
92
|
+
@rows_count += 1
|
|
93
|
+
end
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
@chunk_processor.validate_last_row_complete
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
##
|
|
100
|
+
# Last read row key.
|
|
101
|
+
#
|
|
102
|
+
# @return [String]
|
|
103
|
+
#
|
|
104
|
+
def last_key
|
|
105
|
+
@chunk_processor.last_key
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
##
|
|
109
|
+
# Calculates and returns the read rows limit and row set based on last read key.
|
|
110
|
+
#
|
|
111
|
+
# @param rows_limit [Integer]
|
|
112
|
+
# The read will terminate after committing to N rows' worth of results.
|
|
113
|
+
# The default (zero) is to return all results.
|
|
114
|
+
# @param row_set [Google::Bigtable::V2::RowSet]
|
|
115
|
+
# The row keys and/or ranges to read.
|
|
116
|
+
# If not specified, reads from all rows.
|
|
117
|
+
# A hash of the same form as `Google::Bigtable::V2::RowSet`
|
|
118
|
+
# can also be provided.
|
|
119
|
+
# @return [Integer, Google::Bigtable::V2::RowSet]
|
|
120
|
+
#
|
|
121
|
+
def retry_options rows_limit, row_set
|
|
122
|
+
return [rows_limit, row_set] unless last_key
|
|
123
|
+
|
|
124
|
+
# 1. Reduce the limit by the number of already returned responses.
|
|
125
|
+
rows_limit -= @rows_count if rows_limit
|
|
126
|
+
|
|
127
|
+
# 2. Remove ranges that have already been read, and reduce ranges that
|
|
128
|
+
# include the last read rows
|
|
129
|
+
if last_key
|
|
130
|
+
delete_indexes = []
|
|
131
|
+
|
|
132
|
+
row_set.row_ranges.each_with_index do |range, i|
|
|
133
|
+
if end_key_read? range
|
|
134
|
+
delete_indexes << i
|
|
135
|
+
elsif start_key_read? range
|
|
136
|
+
range.start_key_open = last_key
|
|
137
|
+
end
|
|
138
|
+
end
|
|
139
|
+
|
|
140
|
+
delete_indexes.each { |i| row_set.row_ranges.delete_at i }
|
|
141
|
+
end
|
|
142
|
+
|
|
143
|
+
if row_set.row_ranges.empty?
|
|
144
|
+
row_set.row_ranges <<
|
|
145
|
+
Google::Bigtable::V2::RowRange.new(start_key_open: last_key)
|
|
146
|
+
end
|
|
147
|
+
|
|
148
|
+
# 3. Remove all individual keys before and up to the last read key
|
|
149
|
+
row_set.row_keys.select! { |k| k > last_key }
|
|
150
|
+
|
|
151
|
+
@chunk_processor.reset_to_new_row
|
|
152
|
+
[rows_limit, row_set]
|
|
153
|
+
end
|
|
154
|
+
|
|
155
|
+
##
|
|
156
|
+
# Checks if a read operation is retryable.
|
|
157
|
+
#
|
|
158
|
+
# @return [Boolean]
|
|
159
|
+
#
|
|
160
|
+
def retryable?
|
|
161
|
+
@retry_count < RowsReader::RETRY_LIMIT
|
|
162
|
+
end
|
|
163
|
+
|
|
164
|
+
private
|
|
165
|
+
|
|
166
|
+
##
|
|
167
|
+
# Checks if the start key was already read for the range.
|
|
168
|
+
#
|
|
169
|
+
# @param range [Google::Bigtable::V2::RowRange]
|
|
170
|
+
# @return [Boolean]
|
|
171
|
+
#
|
|
172
|
+
def start_key_read? range
|
|
173
|
+
start_key = if !range.start_key_closed.empty?
|
|
174
|
+
range.start_key_closed
|
|
175
|
+
else
|
|
176
|
+
range.start_key_open
|
|
177
|
+
end
|
|
178
|
+
|
|
179
|
+
start_key.empty? || last_key >= start_key
|
|
180
|
+
end
|
|
181
|
+
|
|
182
|
+
##
|
|
183
|
+
# Checks if the end key was already read for the range.
|
|
184
|
+
#
|
|
185
|
+
# @param range [Google::Bigtable::V2::RowRange]
|
|
186
|
+
# @return [Boolean]
|
|
187
|
+
#
|
|
188
|
+
def end_key_read? range
|
|
189
|
+
end_key = if !range.end_key_closed.empty?
|
|
190
|
+
range.end_key_closed
|
|
191
|
+
else
|
|
192
|
+
range.end_key_open
|
|
193
|
+
end
|
|
194
|
+
|
|
195
|
+
end_key && end_key <= last_key
|
|
196
|
+
end
|
|
197
|
+
end
|
|
198
|
+
end
|
|
199
|
+
end
|
|
200
|
+
end
|
|
@@ -0,0 +1,85 @@
|
|
|
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
|
+
##
|
|
22
|
+
# # SampleRowKey
|
|
23
|
+
#
|
|
24
|
+
# Sample row key with byte offset.
|
|
25
|
+
#
|
|
26
|
+
# NOTE:
|
|
27
|
+
# * row_key : Sorted streamed sequence of sample row keys in the table.
|
|
28
|
+
# The table might have contents before the first row key in the list and after
|
|
29
|
+
# the last one, but a key containing the empty string indicates
|
|
30
|
+
# "end of table" and will be the last response given, if present.
|
|
31
|
+
# Note: that row keys in this list may not have ever been written to or read
|
|
32
|
+
# from, and users should therefore not make any assumptions about the row key
|
|
33
|
+
# structure that are specific to their use case.
|
|
34
|
+
#
|
|
35
|
+
# * offset_bytes : Approximate total storage space used by all rows in the table which precede
|
|
36
|
+
# `row_key`. Buffering the contents of all rows between two subsequent
|
|
37
|
+
# samples would require space roughly equal to the difference in their
|
|
38
|
+
# `offset_bytes` fields.
|
|
39
|
+
#
|
|
40
|
+
# @example
|
|
41
|
+
# require "google/cloud/bigtable"
|
|
42
|
+
#
|
|
43
|
+
# bigtable = Google::Cloud::Bigtable.new
|
|
44
|
+
#
|
|
45
|
+
# table = bigtable.table("my-instance", "my-table")
|
|
46
|
+
#
|
|
47
|
+
# table.sample_row_keys.each do |r|
|
|
48
|
+
# p r
|
|
49
|
+
# end
|
|
50
|
+
#
|
|
51
|
+
class SampleRowKey
|
|
52
|
+
##
|
|
53
|
+
# @return [String] Sample row key.
|
|
54
|
+
attr_reader :key
|
|
55
|
+
|
|
56
|
+
##
|
|
57
|
+
# @return [Integer] Row offset in bytes.
|
|
58
|
+
attr_reader :offset
|
|
59
|
+
|
|
60
|
+
# @private
|
|
61
|
+
#
|
|
62
|
+
# Create SampleRowKey instance.
|
|
63
|
+
#
|
|
64
|
+
# @param key [String]
|
|
65
|
+
# @param offset [Integer] Row offset in bytes.
|
|
66
|
+
#
|
|
67
|
+
def initialize key, offset
|
|
68
|
+
@key = key
|
|
69
|
+
@offset = offset
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
# @private
|
|
73
|
+
#
|
|
74
|
+
# Creates a new SampleRowKey instance from a
|
|
75
|
+
# Google::Bigtable::V2::SampleRowKey.
|
|
76
|
+
# @param grpc [Google::Bigtable::V2::SampleRowKeysResponse]
|
|
77
|
+
# @return [Google::Cloud::Bigtable::SampleRowKey]
|
|
78
|
+
#
|
|
79
|
+
def self.from_grpc grpc
|
|
80
|
+
new grpc.row_key, grpc.offset_bytes
|
|
81
|
+
end
|
|
82
|
+
end
|
|
83
|
+
end
|
|
84
|
+
end
|
|
85
|
+
end
|
|
@@ -0,0 +1,913 @@
|
|
|
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
|
+
# gRPC Cloud Bigtable service, including API methods.
|
|
30
|
+
class Service
|
|
31
|
+
# @private
|
|
32
|
+
attr_accessor :project_id, :credentials, :host, :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,
|
|
39
|
+
# GRPC::Core::ChannelCredentials, Proc]
|
|
40
|
+
# The means for authenticating requests made by the client. This parameter can be one of the following types.
|
|
41
|
+
# `Google::Auth::Credentials` uses the properties of its represented keyfile for authenticating requests made
|
|
42
|
+
# by this client.
|
|
43
|
+
# `String` will be treated as the path to the keyfile to use to construct credentials for this client.
|
|
44
|
+
# `Hash` will be treated as the contents of a keyfile to use to construct credentials for this client.
|
|
45
|
+
# `GRPC::Core::Channel` will be used to make calls through.
|
|
46
|
+
# `GRPC::Core::ChannelCredentials` will be used to set up the gRPC client. The channel credentials should
|
|
47
|
+
# already be composed with a `GRPC::Core::CallCredentials` object.
|
|
48
|
+
# `Proc` will be used as an updater_proc for the gRPC channel. The proc transforms the metadata for requests,
|
|
49
|
+
# generally, to give OAuth credentials.
|
|
50
|
+
# @param timeout [Integer]
|
|
51
|
+
# The default timeout, in seconds, for calls made through this client.
|
|
52
|
+
# @param client_config [Hash]
|
|
53
|
+
# A hash for call options for each method. See Google::Gax#construct_settings for the structure of this data.
|
|
54
|
+
# Falls back to the default config if not specified or the specified config is missing data points.
|
|
55
|
+
#
|
|
56
|
+
def initialize project_id, credentials, host: nil, timeout: nil, client_config: nil
|
|
57
|
+
@project_id = project_id
|
|
58
|
+
@credentials = credentials
|
|
59
|
+
@host = host
|
|
60
|
+
@timeout = timeout
|
|
61
|
+
@client_config = client_config || {}
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
def channel default_host
|
|
65
|
+
require "grpc"
|
|
66
|
+
GRPC::Core::Channel.new((host || default_host), chan_args, chan_creds)
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
def chan_args
|
|
70
|
+
{ "grpc.max_send_message_length" => -1,
|
|
71
|
+
"grpc.max_receive_message_length" => -1,
|
|
72
|
+
"grpc.service_config_disable_resolution" => 1 }
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
def chan_creds
|
|
76
|
+
return credentials if insecure?
|
|
77
|
+
require "grpc"
|
|
78
|
+
GRPC::Core::ChannelCredentials.new.compose GRPC::Core::CallCredentials.new credentials.client.updater_proc
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
##
|
|
82
|
+
# Creates or returns an instance of an instance admin client.
|
|
83
|
+
#
|
|
84
|
+
# @return [Google::Cloud::Bigtable::Admin::V2::BigtableInstanceAdminClient]
|
|
85
|
+
#
|
|
86
|
+
def instances
|
|
87
|
+
return mocked_instances if mocked_instances
|
|
88
|
+
@instances ||= Admin::V2::BigtableInstanceAdminClient.new(
|
|
89
|
+
credentials: channel(Admin::V2::BigtableInstanceAdminClient::SERVICE_ADDRESS),
|
|
90
|
+
timeout: timeout,
|
|
91
|
+
client_config: client_config,
|
|
92
|
+
lib_name: "gccl",
|
|
93
|
+
lib_version: Google::Cloud::Bigtable::VERSION
|
|
94
|
+
)
|
|
95
|
+
end
|
|
96
|
+
attr_accessor :mocked_instances
|
|
97
|
+
|
|
98
|
+
##
|
|
99
|
+
# Creates or returns an instance of a table admin client.
|
|
100
|
+
#
|
|
101
|
+
# @return [Google::Cloud::Bigtable::Admin::V2::BigtableTableAdminClient]
|
|
102
|
+
#
|
|
103
|
+
def tables
|
|
104
|
+
return mocked_tables if mocked_tables
|
|
105
|
+
@tables ||= Admin::V2::BigtableTableAdminClient.new(
|
|
106
|
+
credentials: channel(Admin::V2::BigtableTableAdminClient::SERVICE_ADDRESS),
|
|
107
|
+
timeout: timeout,
|
|
108
|
+
client_config: client_config,
|
|
109
|
+
lib_name: "gccl",
|
|
110
|
+
lib_version: Google::Cloud::Bigtable::VERSION
|
|
111
|
+
)
|
|
112
|
+
end
|
|
113
|
+
attr_accessor :mocked_tables
|
|
114
|
+
|
|
115
|
+
##
|
|
116
|
+
# Creates an instance of a data client.
|
|
117
|
+
#
|
|
118
|
+
# @return [Google::Cloud::Bigtable::V2::BigtableClient]
|
|
119
|
+
#
|
|
120
|
+
def client
|
|
121
|
+
return mocked_client if mocked_client
|
|
122
|
+
@client ||= V2::BigtableClient.new(
|
|
123
|
+
credentials: channel(V2::BigtableClient::SERVICE_ADDRESS),
|
|
124
|
+
timeout: timeout,
|
|
125
|
+
client_config: client_config,
|
|
126
|
+
lib_name: "gccl",
|
|
127
|
+
lib_version: Google::Cloud::Bigtable::VERSION
|
|
128
|
+
)
|
|
129
|
+
end
|
|
130
|
+
attr_accessor :mocked_client
|
|
131
|
+
|
|
132
|
+
def insecure?
|
|
133
|
+
credentials == :this_channel_is_insecure
|
|
134
|
+
end
|
|
135
|
+
|
|
136
|
+
##
|
|
137
|
+
# Creates an instance within a project.
|
|
138
|
+
#
|
|
139
|
+
# @param instance_id [String]
|
|
140
|
+
# The permanent identifier to be used for the new instance.
|
|
141
|
+
#
|
|
142
|
+
# @param instance [Google::Bigtable::Admin::V2::Instance | Hash]
|
|
143
|
+
# @param clusters [Hash{String => Google::Bigtable::Admin::V2::Cluster | Hash}]
|
|
144
|
+
# The clusters to be created in the instance.
|
|
145
|
+
# Note that the cluster ID is the last segment of a cluster name. In the
|
|
146
|
+
# following cluster name, 'mycluster' is the cluster ID:
|
|
147
|
+
# +projects/myproject/instances/myinstance/clusters/mycluster+.
|
|
148
|
+
# Alternatively, provide a hash in the form of `Google::Bigtable::Admin::V2::Cluster`
|
|
149
|
+
# @return [Google::Gax::Operation]
|
|
150
|
+
#
|
|
151
|
+
def create_instance instance_id, instance, clusters
|
|
152
|
+
execute do
|
|
153
|
+
instances.create_instance project_path, instance_id, instance, clusters
|
|
154
|
+
end
|
|
155
|
+
end
|
|
156
|
+
|
|
157
|
+
##
|
|
158
|
+
# Lists the instances in a project.
|
|
159
|
+
#
|
|
160
|
+
# @param token [String]
|
|
161
|
+
# The value of +next_page_token+ returned by a previous call.
|
|
162
|
+
# @return [Google::Bigtable::Admin::V2::ListInstancesResponse]
|
|
163
|
+
#
|
|
164
|
+
def list_instances token: nil
|
|
165
|
+
execute do
|
|
166
|
+
instances.list_instances project_path, page_token: token
|
|
167
|
+
end
|
|
168
|
+
end
|
|
169
|
+
|
|
170
|
+
##
|
|
171
|
+
# Gets information about an instance.
|
|
172
|
+
#
|
|
173
|
+
# @param instance_id [String]
|
|
174
|
+
# Unique ID of the requested instance.
|
|
175
|
+
# @return [Google::Bigtable::Admin::V2::Instance]
|
|
176
|
+
#
|
|
177
|
+
def get_instance instance_id
|
|
178
|
+
execute do
|
|
179
|
+
instances.get_instance instance_path(instance_id)
|
|
180
|
+
end
|
|
181
|
+
end
|
|
182
|
+
|
|
183
|
+
##
|
|
184
|
+
# Partially updates an instance.
|
|
185
|
+
#
|
|
186
|
+
# @param instance [Google::Bigtable::Admin::V2::Instance | Hash]
|
|
187
|
+
# The instance that will (partially) replace the current value.
|
|
188
|
+
# Alternatively, provide a hash in the form of `Google::Bigtable::Admin::V2::Instance.
|
|
189
|
+
# @param update_mask [Google::Protobuf::FieldMask | Hash]
|
|
190
|
+
# List of instance properties to be replaced.
|
|
191
|
+
# Must be explicitly set.
|
|
192
|
+
# Alternatively, provide a hash in the form of `Google::Protobuf::FieldMask`.
|
|
193
|
+
# @return [Google::Gax::Operation]
|
|
194
|
+
#
|
|
195
|
+
def partial_update_instance instance, update_mask
|
|
196
|
+
execute do
|
|
197
|
+
instances.partial_update_instance instance, update_mask
|
|
198
|
+
end
|
|
199
|
+
end
|
|
200
|
+
|
|
201
|
+
##
|
|
202
|
+
# Deletes an instance from a project.
|
|
203
|
+
#
|
|
204
|
+
# @param instance_id [String]
|
|
205
|
+
# Unique ID of the instance to be deleted.
|
|
206
|
+
#
|
|
207
|
+
def delete_instance instance_id
|
|
208
|
+
execute do
|
|
209
|
+
instances.delete_instance(
|
|
210
|
+
instance_path(instance_id)
|
|
211
|
+
)
|
|
212
|
+
end
|
|
213
|
+
end
|
|
214
|
+
|
|
215
|
+
##
|
|
216
|
+
# Creates a cluster within an instance.
|
|
217
|
+
#
|
|
218
|
+
# @param instance_id [String]
|
|
219
|
+
# Unique ID of the instance in which to create the new cluster
|
|
220
|
+
# @param cluster_id [String]
|
|
221
|
+
# Unique permanent identifier for the new cluster
|
|
222
|
+
# @param cluster [Google::Bigtable::Admin::V2::Cluster | Hash]
|
|
223
|
+
# The cluster to be created.
|
|
224
|
+
# Alternatively, provide a hash in the form of `Google::Bigtable::Admin::V2::Cluster`
|
|
225
|
+
#
|
|
226
|
+
# @return [Google::Gax::Operation]
|
|
227
|
+
#
|
|
228
|
+
def create_cluster instance_id, cluster_id, cluster
|
|
229
|
+
cluster.location = location_path cluster.location unless cluster.location == ""
|
|
230
|
+
|
|
231
|
+
execute do
|
|
232
|
+
instances.create_cluster instance_path(instance_id), cluster_id, cluster
|
|
233
|
+
end
|
|
234
|
+
end
|
|
235
|
+
|
|
236
|
+
##
|
|
237
|
+
# Lists information about clusters in an instance.
|
|
238
|
+
#
|
|
239
|
+
# @param instance_id [String]
|
|
240
|
+
# Unique ID of the instance for which a list of clusters is requested.
|
|
241
|
+
# @param token [String]
|
|
242
|
+
# The value of +next_page_token+ returned by a previous call.
|
|
243
|
+
# @return [Google::Bigtable::Admin::V2::ListClustersResponse]
|
|
244
|
+
#
|
|
245
|
+
def list_clusters instance_id, token: nil
|
|
246
|
+
execute do
|
|
247
|
+
instances.list_clusters instance_path(instance_id), page_token: token
|
|
248
|
+
end
|
|
249
|
+
end
|
|
250
|
+
|
|
251
|
+
##
|
|
252
|
+
# Gets information about a cluster.
|
|
253
|
+
#
|
|
254
|
+
# @param instance_id [String]
|
|
255
|
+
# Unique ID of the instance the cluster is in.
|
|
256
|
+
# @param cluster_id [String]
|
|
257
|
+
# Unique ID of the requested cluster.
|
|
258
|
+
# @return [Google::Bigtable::Admin::V2::Cluster]
|
|
259
|
+
#
|
|
260
|
+
def get_cluster instance_id, cluster_id
|
|
261
|
+
execute do
|
|
262
|
+
instances.get_cluster cluster_path(instance_id, cluster_id)
|
|
263
|
+
end
|
|
264
|
+
end
|
|
265
|
+
|
|
266
|
+
##
|
|
267
|
+
# Updates a cluster within an instance.
|
|
268
|
+
#
|
|
269
|
+
# @param instance_id [String]
|
|
270
|
+
# Unique ID of the instance the cluster is in.
|
|
271
|
+
# @param cluster_id [String]
|
|
272
|
+
# Unique ID of the cluster.
|
|
273
|
+
# @param location [String]
|
|
274
|
+
# Location of this cluster's nodes and storage. For best
|
|
275
|
+
# performance, clients should be located as close as possible to this
|
|
276
|
+
# cluster. Requird format for the location string:
|
|
277
|
+
# +projects/<project>/locations/<zone>+.
|
|
278
|
+
# @param serve_nodes [Integer]
|
|
279
|
+
# The number of nodes allocated to this cluster. More nodes enable higher
|
|
280
|
+
# throughput and more consistent performance.
|
|
281
|
+
# @return [Google::Gax::Operation]
|
|
282
|
+
#
|
|
283
|
+
def update_cluster instance_id, cluster_id, location, serve_nodes
|
|
284
|
+
execute do
|
|
285
|
+
instances.update_cluster cluster_path(instance_id, cluster_id), location, serve_nodes
|
|
286
|
+
end
|
|
287
|
+
end
|
|
288
|
+
|
|
289
|
+
##
|
|
290
|
+
# Deletes a cluster from an instance.
|
|
291
|
+
#
|
|
292
|
+
# @param instance_id [String]
|
|
293
|
+
# Unique ID of the instance the cluster is in.
|
|
294
|
+
# @param cluster_id [String]
|
|
295
|
+
# Unique ID of the cluster to be deleted.
|
|
296
|
+
#
|
|
297
|
+
def delete_cluster instance_id, cluster_id
|
|
298
|
+
execute do
|
|
299
|
+
instances.delete_cluster cluster_path(instance_id, cluster_id)
|
|
300
|
+
end
|
|
301
|
+
end
|
|
302
|
+
|
|
303
|
+
##
|
|
304
|
+
# Creates a new table in the specified instance.
|
|
305
|
+
# Optionally, creates the table with a full set of initial column families.
|
|
306
|
+
#
|
|
307
|
+
# @param instance_id [String]
|
|
308
|
+
# Unique ID of the instance to create the table in.
|
|
309
|
+
# @param table_id [String]
|
|
310
|
+
# Unique, permanent identifier for the new table.
|
|
311
|
+
# @param table [Google::Bigtable::Admin::V2::Table | Hash]
|
|
312
|
+
# The table to create.
|
|
313
|
+
# Alternatively, provide a hash in the form of `Google::Bigtable::Admin::V2::Table`.
|
|
314
|
+
# @param initial_splits [Array<Google::Bigtable::Admin::V2::CreateTableRequest::Split | Hash>]
|
|
315
|
+
# The optional list of row keys that will be used to initially split the
|
|
316
|
+
# table into several tablets (tablets are similar to HBase regions).
|
|
317
|
+
# Given two split keys, +s1+ and +s2+, three tablets will be created,
|
|
318
|
+
# spanning the key ranges: +[, s1), [s1, s2), [s2, )+.
|
|
319
|
+
#
|
|
320
|
+
# Example:
|
|
321
|
+
#
|
|
322
|
+
# * Row keys := +["a", "apple", "custom", "customer_1", "customer_2",+
|
|
323
|
+
# +"other", "zz"]+
|
|
324
|
+
# * initial_split_keys := +["apple", "customer_1", "customer_2", "other"]+
|
|
325
|
+
# * Key assignment:
|
|
326
|
+
# * Tablet 1 +[, apple) => {"a"}.+
|
|
327
|
+
# * Tablet 2 +[apple, customer_1) => {"apple", "custom"}.+
|
|
328
|
+
# * Tablet 3 +[customer_1, customer_2) => {"customer_1"}.+
|
|
329
|
+
# * Tablet 4 +[customer_2, other) => {"customer_2"}.+
|
|
330
|
+
# * Tablet 5 +[other, ) => {"other", "zz"}.+
|
|
331
|
+
# Alternatively, provide a hash in the form of
|
|
332
|
+
# `Google::Bigtable::Admin::V2::CreateTableRequest::Split`
|
|
333
|
+
# @return [Google::Bigtable::Admin::V2::Table]
|
|
334
|
+
#
|
|
335
|
+
def create_table instance_id, table_id, table, initial_splits: nil
|
|
336
|
+
initial_splits = initial_splits.map { |key| { key: key } } if initial_splits
|
|
337
|
+
|
|
338
|
+
execute do
|
|
339
|
+
tables.create_table instance_path(instance_id), table_id, table, initial_splits: initial_splits
|
|
340
|
+
end
|
|
341
|
+
end
|
|
342
|
+
|
|
343
|
+
##
|
|
344
|
+
# Lists all tables in an instance.
|
|
345
|
+
#
|
|
346
|
+
# @param instance_id [String]
|
|
347
|
+
# Unique ID of the instance for which tables should be listed.
|
|
348
|
+
# @param view [Google::Bigtable::Admin::V2::Table::View]
|
|
349
|
+
# View to be applied to the returned tables' fields.
|
|
350
|
+
# Defaults to +NAME_ONLY+ if unspecified; no others are currently supported.
|
|
351
|
+
# @return [Google::Gax::PagedEnumerable<Google::Bigtable::Admin::V2::Table>]
|
|
352
|
+
# An enumerable of Google::Bigtable::Admin::V2::Table instances.
|
|
353
|
+
# See Google::Gax::PagedEnumerable documentation for other
|
|
354
|
+
# operations such as per-page iteration or access to the response.
|
|
355
|
+
#
|
|
356
|
+
def list_tables instance_id, view: nil
|
|
357
|
+
execute do
|
|
358
|
+
tables.list_tables instance_path(instance_id), view: view
|
|
359
|
+
end
|
|
360
|
+
end
|
|
361
|
+
|
|
362
|
+
##
|
|
363
|
+
# Gets metadata about the specified table.
|
|
364
|
+
#
|
|
365
|
+
# @param instance_id [String]
|
|
366
|
+
# Unique ID of the instance the table is in.
|
|
367
|
+
# @param table_id [String]
|
|
368
|
+
# Unique ID of the requested table.
|
|
369
|
+
# @param view [Google::Bigtable::Admin::V2::Table::View]
|
|
370
|
+
# View to be applied to the returned table's fields.
|
|
371
|
+
# Defaults to +SCHEMA_VIEW+ if unspecified.
|
|
372
|
+
# @return [Google::Bigtable::Admin::V2::Table]
|
|
373
|
+
#
|
|
374
|
+
def get_table instance_id, table_id, view: nil
|
|
375
|
+
execute do
|
|
376
|
+
tables.get_table table_path(instance_id, table_id), view: view
|
|
377
|
+
end
|
|
378
|
+
end
|
|
379
|
+
|
|
380
|
+
##
|
|
381
|
+
# Permanently deletes a table and all of its data.
|
|
382
|
+
#
|
|
383
|
+
# @param instance_id [String]
|
|
384
|
+
# Unique ID of the instance the table is in.
|
|
385
|
+
# @param table_id [String]
|
|
386
|
+
# Unique ID of the table to be deleted.
|
|
387
|
+
#
|
|
388
|
+
def delete_table instance_id, table_id
|
|
389
|
+
execute do
|
|
390
|
+
tables.delete_table table_path(instance_id, table_id)
|
|
391
|
+
end
|
|
392
|
+
end
|
|
393
|
+
|
|
394
|
+
##
|
|
395
|
+
# Performs a series of column family modifications on the specified table.
|
|
396
|
+
# Either all or none of the modifications will occur before this method
|
|
397
|
+
# returns. Data requests received prior to completion of this method may reach a table
|
|
398
|
+
# in which only some modifications have taken effect.
|
|
399
|
+
#
|
|
400
|
+
# @param instance_id [String]
|
|
401
|
+
# Unique ID of the instance the table is in.
|
|
402
|
+
# @param table_id [String]
|
|
403
|
+
# Unique ID of the table whose families should be modified.
|
|
404
|
+
# @param modifications [Array<Google::Bigtable::Admin::V2::ModifyColumnFamiliesRequest::Modification | Hash>]
|
|
405
|
+
# Modifications to be atomically applied to the specified table's families.
|
|
406
|
+
# Entries are applied in order, meaning that earlier modifications can be
|
|
407
|
+
# masked by later ones (in the case of repeated updates to the same family,
|
|
408
|
+
# for example).
|
|
409
|
+
# Alternatively, provide a hash in the form of
|
|
410
|
+
# `Google::Bigtable::Admin::V2::ModifyColumnFamiliesRequest::Modification`.
|
|
411
|
+
# @return [Google::Bigtable::Admin::V2::Table]
|
|
412
|
+
#
|
|
413
|
+
def modify_column_families instance_id, table_id, modifications
|
|
414
|
+
execute do
|
|
415
|
+
tables.modify_column_families table_path(instance_id, table_id), modifications
|
|
416
|
+
end
|
|
417
|
+
end
|
|
418
|
+
|
|
419
|
+
##
|
|
420
|
+
# Generates a consistency token for a table.
|
|
421
|
+
# The consistency token can be be used in CheckConsistency to check whether
|
|
422
|
+
# mutations to the table that finished before this call started have been replicated.
|
|
423
|
+
# The token will be available for 90 days.
|
|
424
|
+
#
|
|
425
|
+
# @param instance_id [String]
|
|
426
|
+
# Unique ID of the instance the table is in.
|
|
427
|
+
# @param table_id [String]
|
|
428
|
+
# Unique ID of the table the consistency token is for.
|
|
429
|
+
# @return [Google::Bigtable::Admin::V2::GenerateConsistencyTokenResponse]
|
|
430
|
+
#
|
|
431
|
+
def generate_consistency_token instance_id, table_id
|
|
432
|
+
execute do
|
|
433
|
+
tables.generate_consistency_token table_path(instance_id, table_id)
|
|
434
|
+
end
|
|
435
|
+
end
|
|
436
|
+
|
|
437
|
+
##
|
|
438
|
+
# Checks replication consistency based on a consistency token.
|
|
439
|
+
# Determines if replication has caught up, based on the conditions in the token
|
|
440
|
+
# and the check request.
|
|
441
|
+
#
|
|
442
|
+
# @param instance_id [String]
|
|
443
|
+
# Unique ID of the instance the table is in.
|
|
444
|
+
# @param table_id [String]
|
|
445
|
+
# Unique ID of the table to check for replication consistency.
|
|
446
|
+
# @param token [String] Consistency token
|
|
447
|
+
# The token created for the table using GenerateConsistencyToken.
|
|
448
|
+
# @return [Google::Bigtable::Admin::V2::CheckConsistencyResponse]
|
|
449
|
+
#
|
|
450
|
+
def check_consistency instance_id, table_id, token
|
|
451
|
+
execute do
|
|
452
|
+
tables.check_consistency table_path(instance_id, table_id), token
|
|
453
|
+
end
|
|
454
|
+
end
|
|
455
|
+
|
|
456
|
+
##
|
|
457
|
+
# Permanently deletes a row range from a table. The request can
|
|
458
|
+
# specify whether to delete all rows in a table or only rows that match a
|
|
459
|
+
# particular row key prefix.
|
|
460
|
+
#
|
|
461
|
+
# @param instance_id [String]
|
|
462
|
+
# Unique ID of the instance the table is in.
|
|
463
|
+
# @param table_id [String]
|
|
464
|
+
# Unique ID of the table to delete a range of rows from.
|
|
465
|
+
# @param row_key_prefix [String]
|
|
466
|
+
# All rows whose row keys start with this row key prefix will be deleted.
|
|
467
|
+
# Prefix cannot be zero length.
|
|
468
|
+
# @param delete_all_data_from_table [true, false]
|
|
469
|
+
# If true, delete all rows in the table. Setting this to false is a no-op.
|
|
470
|
+
# @param timeout [Integer]
|
|
471
|
+
# Sets the API call timeout if deadline exceeds exception.
|
|
472
|
+
#
|
|
473
|
+
def drop_row_range instance_id, table_id, row_key_prefix: nil, delete_all_data_from_table: nil, timeout: nil
|
|
474
|
+
call_options = nil
|
|
475
|
+
|
|
476
|
+
# Pass a timeout with a larger value if the drop operation throws
|
|
477
|
+
# an error for timeout time.
|
|
478
|
+
if timeout
|
|
479
|
+
retry_options = Google::Gax::RetryOptions.new(
|
|
480
|
+
[],
|
|
481
|
+
Google::Gax::BackoffSettings.new(0, 0, 0, timeout * 1000, 0, 0, 0)
|
|
482
|
+
)
|
|
483
|
+
call_options = Google::Gax::CallOptions.new retry_options: retry_options
|
|
484
|
+
end
|
|
485
|
+
|
|
486
|
+
execute do
|
|
487
|
+
tables.drop_row_range(
|
|
488
|
+
table_path(instance_id, table_id),
|
|
489
|
+
row_key_prefix: row_key_prefix,
|
|
490
|
+
delete_all_data_from_table: delete_all_data_from_table,
|
|
491
|
+
options: call_options
|
|
492
|
+
)
|
|
493
|
+
end
|
|
494
|
+
end
|
|
495
|
+
|
|
496
|
+
##
|
|
497
|
+
# Creates an app profile within an instance.
|
|
498
|
+
#
|
|
499
|
+
# @param instance_id [String]
|
|
500
|
+
# Unique ID of the instance.
|
|
501
|
+
# @param app_profile_id [String]
|
|
502
|
+
# The permanent identifier for the new app profile within its
|
|
503
|
+
# instance.
|
|
504
|
+
# @param app_profile [Google::Bigtable::Admin::V2::AppProfile | Hash]
|
|
505
|
+
# The app profile to be created.
|
|
506
|
+
# Alternatively, provide a hash in the form of `Google::Bigtable::Admin::V2::AppProfile`.
|
|
507
|
+
# @param ignore_warnings [Boolean]
|
|
508
|
+
# If true, ignore safety checks when creating the app profile.
|
|
509
|
+
# @return [Google::Bigtable::Admin::V2::AppProfile]
|
|
510
|
+
#
|
|
511
|
+
def create_app_profile instance_id, app_profile_id, app_profile, ignore_warnings: nil
|
|
512
|
+
execute do
|
|
513
|
+
instances.create_app_profile(
|
|
514
|
+
instance_path(instance_id),
|
|
515
|
+
app_profile_id,
|
|
516
|
+
app_profile,
|
|
517
|
+
ignore_warnings: ignore_warnings
|
|
518
|
+
)
|
|
519
|
+
end
|
|
520
|
+
end
|
|
521
|
+
|
|
522
|
+
##
|
|
523
|
+
# Gets information about an app profile.
|
|
524
|
+
#
|
|
525
|
+
# @param instance_id [String]
|
|
526
|
+
# Unique ID of the instance.
|
|
527
|
+
# @param app_profile_id [String]
|
|
528
|
+
# Unique ID of the requested app profile.
|
|
529
|
+
# @return [Google::Bigtable::Admin::V2::AppProfile]
|
|
530
|
+
#
|
|
531
|
+
def get_app_profile instance_id, app_profile_id
|
|
532
|
+
execute do
|
|
533
|
+
instances.get_app_profile app_profile_path(instance_id, app_profile_id)
|
|
534
|
+
end
|
|
535
|
+
end
|
|
536
|
+
|
|
537
|
+
##
|
|
538
|
+
# Lists information about app profiles in an instance.
|
|
539
|
+
#
|
|
540
|
+
# @param instance_id [String]
|
|
541
|
+
# Unique ID of the instance
|
|
542
|
+
# @return [Google::Gax::PagedEnumerable<Google::Bigtable::Admin::V2::AppProfile>]
|
|
543
|
+
# An enumerable of Google::Bigtable::Admin::V2::AppProfile instances.
|
|
544
|
+
# See Google::Gax::PagedEnumerable documentation for other
|
|
545
|
+
# operations such as per-page iteration or access to the response
|
|
546
|
+
# object.
|
|
547
|
+
#
|
|
548
|
+
def list_app_profiles instance_id
|
|
549
|
+
execute do
|
|
550
|
+
instances.list_app_profiles instance_path(instance_id)
|
|
551
|
+
end
|
|
552
|
+
end
|
|
553
|
+
|
|
554
|
+
##
|
|
555
|
+
# Updates an app profile within an instance.
|
|
556
|
+
#
|
|
557
|
+
# @param app_profile [Google::Bigtable::Admin::V2::AppProfile | Hash]
|
|
558
|
+
# The app profile that will (partially) replace the current value.
|
|
559
|
+
# Alternatively, provide a hash in the form of
|
|
560
|
+
# `Google::Bigtable::Admin::V2::AppProfile`.
|
|
561
|
+
# @param update_mask [Google::Protobuf::FieldMask | Hash]
|
|
562
|
+
# The subset of app profile fields that should be replaced.
|
|
563
|
+
# If unset, all fields will be replaced.
|
|
564
|
+
# Alternatively, provide a hash similar to `Google::Protobuf::FieldMask`.
|
|
565
|
+
# @param ignore_warnings [Boolean]
|
|
566
|
+
# If true, ignore safety checks when updating the app profile.
|
|
567
|
+
# @return [Google::Longrunning::Operation]
|
|
568
|
+
#
|
|
569
|
+
def update_app_profile app_profile, update_mask, ignore_warnings: nil
|
|
570
|
+
execute do
|
|
571
|
+
instances.update_app_profile app_profile, update_mask, ignore_warnings: ignore_warnings
|
|
572
|
+
end
|
|
573
|
+
end
|
|
574
|
+
|
|
575
|
+
##
|
|
576
|
+
# Deletes an app profile from an instance.
|
|
577
|
+
#
|
|
578
|
+
# @param instance_id [String]
|
|
579
|
+
# Unique ID of the instance.
|
|
580
|
+
# @param app_profile_id [String]
|
|
581
|
+
# Unique ID of the app profile to be deleted.
|
|
582
|
+
# @param ignore_warnings [Boolean]
|
|
583
|
+
# If true, ignore safety checks when deleting the app profile.
|
|
584
|
+
#
|
|
585
|
+
def delete_app_profile instance_id, app_profile_id, ignore_warnings: nil
|
|
586
|
+
execute do
|
|
587
|
+
instances.delete_app_profile app_profile_path(instance_id, app_profile_id), ignore_warnings
|
|
588
|
+
end
|
|
589
|
+
end
|
|
590
|
+
|
|
591
|
+
##
|
|
592
|
+
# Gets the access control policy for an instance resource. Returns an empty
|
|
593
|
+
# policy if an instance exists but does not have a policy set.
|
|
594
|
+
#
|
|
595
|
+
# @param instance_id [String]
|
|
596
|
+
# Unique ID of the instance for which the policy is being requested.
|
|
597
|
+
# @return [Google::Iam::V1::Policy]
|
|
598
|
+
#
|
|
599
|
+
def get_instance_policy instance_id
|
|
600
|
+
execute do
|
|
601
|
+
instances.get_iam_policy instance_path(instance_id)
|
|
602
|
+
end
|
|
603
|
+
end
|
|
604
|
+
|
|
605
|
+
##
|
|
606
|
+
# Sets the access control policy on an instance resource. Replaces any
|
|
607
|
+
# existing policy.
|
|
608
|
+
#
|
|
609
|
+
# @param instance_id [String]
|
|
610
|
+
# Unique ID of the instance the policy is for.
|
|
611
|
+
# @param policy [Google::Iam::V1::Policy | Hash]
|
|
612
|
+
# REQUIRED: The complete policy to be applied to the +resource+. The size of
|
|
613
|
+
# the policy is limited to a few 10s of KB. An empty policy is valid
|
|
614
|
+
# for Cloud Bigtable, but certain Cloud Platform services (such as Projects)
|
|
615
|
+
# might reject an empty policy.
|
|
616
|
+
# Alternatively, provide a hash similar to `Google::Iam::V1::Policy`.
|
|
617
|
+
# @return [Google::Iam::V1::Policy]
|
|
618
|
+
#
|
|
619
|
+
def set_instance_policy instance_id, policy
|
|
620
|
+
execute do
|
|
621
|
+
instances.set_iam_policy instance_path(instance_id), policy
|
|
622
|
+
end
|
|
623
|
+
end
|
|
624
|
+
|
|
625
|
+
##
|
|
626
|
+
# Returns permissions that the caller has for the specified instance resource.
|
|
627
|
+
#
|
|
628
|
+
# @param instance_id [String]
|
|
629
|
+
# The instance ID that the policy detail is being requested for.
|
|
630
|
+
# @param permissions [Array<String>]
|
|
631
|
+
# The set of permissions to check for the +resource+. Permissions with
|
|
632
|
+
# wildcards (such as '*' or 'storage.*') are not allowed. For more
|
|
633
|
+
# information see
|
|
634
|
+
# [IAM Overview](https://cloud.google.com/iam/docs/overview#permissions).
|
|
635
|
+
# @return [Google::Iam::V1::TestIamPermissionsResponse]
|
|
636
|
+
#
|
|
637
|
+
def test_instance_permissions instance_id, permissions
|
|
638
|
+
execute do
|
|
639
|
+
instances.test_iam_permissions instance_path(instance_id), permissions
|
|
640
|
+
end
|
|
641
|
+
end
|
|
642
|
+
|
|
643
|
+
##
|
|
644
|
+
# Gets the access control policy for an table resource. Returns an empty
|
|
645
|
+
# policy if an table exists but does not have a policy set.
|
|
646
|
+
#
|
|
647
|
+
# @param table_id [String]
|
|
648
|
+
# Unique ID of the table for which the policy is being requested.
|
|
649
|
+
# @return [Google::Iam::V1::Policy]
|
|
650
|
+
#
|
|
651
|
+
def get_table_policy instance_id, table_id
|
|
652
|
+
execute do
|
|
653
|
+
tables.get_iam_policy table_path(instance_id, table_id)
|
|
654
|
+
end
|
|
655
|
+
end
|
|
656
|
+
|
|
657
|
+
##
|
|
658
|
+
# Sets the access control policy on an table resource. Replaces any
|
|
659
|
+
# existing policy.
|
|
660
|
+
#
|
|
661
|
+
# @param table_id [String]
|
|
662
|
+
# Unique ID of the table the policy is for.
|
|
663
|
+
# @param policy [Google::Iam::V1::Policy | Hash]
|
|
664
|
+
# REQUIRED: The complete policy to be applied to the +resource+. The size of
|
|
665
|
+
# the policy is limited to a few 10s of KB. An empty policy is valid
|
|
666
|
+
# for Cloud Bigtable, but certain Cloud Platform services (such as Projects)
|
|
667
|
+
# might reject an empty policy.
|
|
668
|
+
# Alternatively, provide a hash similar to `Google::Iam::V1::Policy`.
|
|
669
|
+
# @return [Google::Iam::V1::Policy]
|
|
670
|
+
#
|
|
671
|
+
def set_table_policy instance_id, table_id, policy
|
|
672
|
+
execute do
|
|
673
|
+
tables.set_iam_policy table_path(instance_id, table_id), policy
|
|
674
|
+
end
|
|
675
|
+
end
|
|
676
|
+
|
|
677
|
+
##
|
|
678
|
+
# Returns permissions that the caller has for the specified table resource.
|
|
679
|
+
#
|
|
680
|
+
# @param table_id [String]
|
|
681
|
+
# The table ID that the policy detail is being requested for.
|
|
682
|
+
# @param permissions [Array<String>]
|
|
683
|
+
# The set of permissions to check for the +resource+. Permissions with
|
|
684
|
+
# wildcards (such as '*' or 'storage.*') are not allowed. For more
|
|
685
|
+
# information see
|
|
686
|
+
# [IAM Overview](https://cloud.google.com/iam/docs/overview#permissions).
|
|
687
|
+
# @return [Google::Iam::V1::TestIamPermissionsResponse]
|
|
688
|
+
#
|
|
689
|
+
def test_table_permissions instance_id, table_id, permissions
|
|
690
|
+
execute do
|
|
691
|
+
tables.test_iam_permissions table_path(instance_id, table_id), permissions
|
|
692
|
+
end
|
|
693
|
+
end
|
|
694
|
+
|
|
695
|
+
def read_rows instance_id, table_id, app_profile_id: nil, rows: nil, filter: nil, rows_limit: nil
|
|
696
|
+
# execute is not used because error handling is in ReadOperations#read_rows
|
|
697
|
+
client.read_rows table_path(instance_id, table_id),
|
|
698
|
+
rows: rows,
|
|
699
|
+
filter: filter,
|
|
700
|
+
rows_limit: rows_limit,
|
|
701
|
+
app_profile_id: app_profile_id
|
|
702
|
+
end
|
|
703
|
+
|
|
704
|
+
def sample_row_keys table_name, app_profile_id: nil
|
|
705
|
+
execute do
|
|
706
|
+
client.sample_row_keys table_name, app_profile_id: app_profile_id
|
|
707
|
+
end
|
|
708
|
+
end
|
|
709
|
+
|
|
710
|
+
def mutate_row table_name, row_key, mutations, app_profile_id: nil
|
|
711
|
+
execute do
|
|
712
|
+
client.mutate_row table_name, row_key, mutations, app_profile_id: app_profile_id
|
|
713
|
+
end
|
|
714
|
+
end
|
|
715
|
+
|
|
716
|
+
def mutate_rows table_name, entries, app_profile_id: nil
|
|
717
|
+
execute do
|
|
718
|
+
client.mutate_rows table_name, entries, app_profile_id: app_profile_id
|
|
719
|
+
end
|
|
720
|
+
end
|
|
721
|
+
|
|
722
|
+
def check_and_mutate_row table_name, row_key, app_profile_id: nil, predicate_filter: nil, true_mutations: nil,
|
|
723
|
+
false_mutations: nil
|
|
724
|
+
execute do
|
|
725
|
+
client.check_and_mutate_row table_name, row_key, app_profile_id: app_profile_id,
|
|
726
|
+
predicate_filter: predicate_filter, true_mutations: true_mutations,
|
|
727
|
+
false_mutations: false_mutations
|
|
728
|
+
end
|
|
729
|
+
end
|
|
730
|
+
|
|
731
|
+
def read_modify_write_row table_name, row_key, rules, app_profile_id: nil
|
|
732
|
+
execute do
|
|
733
|
+
client.read_modify_write_row table_name, row_key, rules, app_profile_id: app_profile_id
|
|
734
|
+
end
|
|
735
|
+
end
|
|
736
|
+
|
|
737
|
+
##
|
|
738
|
+
# Starts creating a new backup. The underlying Google::Longrunning::Operation tracks creation of the backup.
|
|
739
|
+
#
|
|
740
|
+
# @return [Google::Gax::Operation]
|
|
741
|
+
#
|
|
742
|
+
def create_backup instance_id:, cluster_id:, backup_id:, source_table_id:, expire_time:
|
|
743
|
+
backup = Google::Bigtable::Admin::V2::Backup.new source_table: table_path(instance_id, source_table_id),
|
|
744
|
+
expire_time: expire_time
|
|
745
|
+
execute do
|
|
746
|
+
tables.create_backup cluster_path(instance_id, cluster_id), backup_id, backup
|
|
747
|
+
end
|
|
748
|
+
end
|
|
749
|
+
|
|
750
|
+
##
|
|
751
|
+
# @return [Google::Bigtable::Admin::V2::Backup]
|
|
752
|
+
#
|
|
753
|
+
def get_backup instance_id, cluster_id, backup_id
|
|
754
|
+
execute do
|
|
755
|
+
tables.get_backup backup_path(instance_id, cluster_id, backup_id)
|
|
756
|
+
end
|
|
757
|
+
end
|
|
758
|
+
|
|
759
|
+
##
|
|
760
|
+
# @return [Google::Gax::PagedEnumerable<Google::Bigtable::Admin::V2::Backup>]
|
|
761
|
+
#
|
|
762
|
+
def list_backups instance_id, cluster_id
|
|
763
|
+
execute do
|
|
764
|
+
tables.list_backups cluster_path(instance_id, cluster_id)
|
|
765
|
+
end
|
|
766
|
+
end
|
|
767
|
+
|
|
768
|
+
##
|
|
769
|
+
# @param backup [Google::Bigtable::Admin::V2::Backup | Hash]
|
|
770
|
+
# @param fields [Array(String|Symbol)] the paths of fields to be updated
|
|
771
|
+
#
|
|
772
|
+
def update_backup backup, fields
|
|
773
|
+
mask = Google::Protobuf::FieldMask.new paths: fields.map(&:to_s)
|
|
774
|
+
execute do
|
|
775
|
+
tables.update_backup backup, mask
|
|
776
|
+
end
|
|
777
|
+
end
|
|
778
|
+
|
|
779
|
+
def delete_backup instance_id, cluster_id, backup_id
|
|
780
|
+
execute do
|
|
781
|
+
tables.delete_backup backup_path(instance_id, cluster_id, backup_id)
|
|
782
|
+
end
|
|
783
|
+
end
|
|
784
|
+
|
|
785
|
+
##
|
|
786
|
+
# Create a new table by restoring from a completed backup.
|
|
787
|
+
#
|
|
788
|
+
# @param table_id [String] The table ID for the new table. This table must not yet exist.
|
|
789
|
+
# @param instance_id [String] The instance ID for the source backup. The table will be created in this instance.
|
|
790
|
+
# @param cluster_id [String] The cluster ID for the source backup.
|
|
791
|
+
# @param backup_id [String] The backup ID for the source backup.
|
|
792
|
+
#
|
|
793
|
+
# @return [Google::Gax::Operation] The {Google::Longrunning::Operation#metadata metadata} field type is
|
|
794
|
+
# {Google::Bigtable::Admin::RestoreTableMetadata RestoreTableMetadata}. The
|
|
795
|
+
# {Google::Longrunning::Operation#response response} type is {Google::Bigtable::Admin::V2::Table Table}, if
|
|
796
|
+
# successful.
|
|
797
|
+
#
|
|
798
|
+
def restore_table table_id, instance_id, cluster_id, backup_id
|
|
799
|
+
execute do
|
|
800
|
+
tables.restore_table instance_path(instance_id),
|
|
801
|
+
table_id: table_id,
|
|
802
|
+
backup: backup_path(instance_id, cluster_id, backup_id)
|
|
803
|
+
end
|
|
804
|
+
end
|
|
805
|
+
|
|
806
|
+
##
|
|
807
|
+
# Executes the API call and wrap errors to {Google::Cloud::Error}.
|
|
808
|
+
#
|
|
809
|
+
# @raise [Google::Cloud::Error]
|
|
810
|
+
#
|
|
811
|
+
def execute
|
|
812
|
+
yield
|
|
813
|
+
rescue Google::Gax::GaxError => e
|
|
814
|
+
raise Google::Cloud::Error.from_error(e.cause)
|
|
815
|
+
rescue GRPC::BadStatus => e
|
|
816
|
+
raise Google::Cloud::Error.from_error(e)
|
|
817
|
+
end
|
|
818
|
+
|
|
819
|
+
##
|
|
820
|
+
# Creates a formatted project path.
|
|
821
|
+
#
|
|
822
|
+
# @return [String]
|
|
823
|
+
# Formatted project path
|
|
824
|
+
# +projects/<project>+
|
|
825
|
+
#
|
|
826
|
+
def project_path
|
|
827
|
+
Admin::V2::BigtableInstanceAdminClient.project_path project_id
|
|
828
|
+
end
|
|
829
|
+
|
|
830
|
+
##
|
|
831
|
+
# Creates a formatted instance path.
|
|
832
|
+
#
|
|
833
|
+
# @param instance_id [String]
|
|
834
|
+
# @return [String]
|
|
835
|
+
# Formatted instance path
|
|
836
|
+
# +projects/<project>/instances/[a-z][a-z0-9\\-]+[a-z0-9]+.
|
|
837
|
+
#
|
|
838
|
+
def instance_path instance_id
|
|
839
|
+
Admin::V2::BigtableInstanceAdminClient.instance_path project_id, instance_id
|
|
840
|
+
end
|
|
841
|
+
|
|
842
|
+
##
|
|
843
|
+
# Creates a formatted cluster path.
|
|
844
|
+
#
|
|
845
|
+
# @param instance_id [String]
|
|
846
|
+
# @param cluster_id [String]
|
|
847
|
+
# @return [String]
|
|
848
|
+
# Formatted cluster path
|
|
849
|
+
# +projects/<project>/instances/<instance>/clusters/<cluster>+.
|
|
850
|
+
#
|
|
851
|
+
def cluster_path instance_id, cluster_id
|
|
852
|
+
Admin::V2::BigtableInstanceAdminClient.cluster_path project_id, instance_id, cluster_id
|
|
853
|
+
end
|
|
854
|
+
|
|
855
|
+
##
|
|
856
|
+
# Creates a formatted location path.
|
|
857
|
+
#
|
|
858
|
+
# @param location [String]
|
|
859
|
+
# zone name i.e us-east1-b
|
|
860
|
+
# @return [String]
|
|
861
|
+
# Formatted location path
|
|
862
|
+
# +projects/<project_id>/locations/<location>+.
|
|
863
|
+
#
|
|
864
|
+
def location_path location
|
|
865
|
+
Admin::V2::BigtableInstanceAdminClient.location_path project_id, location
|
|
866
|
+
end
|
|
867
|
+
|
|
868
|
+
##
|
|
869
|
+
# Creates a formatted table path.
|
|
870
|
+
#
|
|
871
|
+
# @param table_id [String]
|
|
872
|
+
# @return [String]
|
|
873
|
+
# Formatted table path
|
|
874
|
+
# +projects/<project>/instances/<instance>/tables/<table>+
|
|
875
|
+
#
|
|
876
|
+
def table_path instance_id, table_id
|
|
877
|
+
Admin::V2::BigtableTableAdminClient.table_path project_id, instance_id, table_id
|
|
878
|
+
end
|
|
879
|
+
|
|
880
|
+
##
|
|
881
|
+
# Creates a formatted app profile path.
|
|
882
|
+
#
|
|
883
|
+
# @param instance_id [String]
|
|
884
|
+
# @param app_profile_id [String]
|
|
885
|
+
# @return [String]
|
|
886
|
+
# Formatted snapshot path
|
|
887
|
+
# +projects/<project>/instances/<instance>/appProfiles/<app_profile>+
|
|
888
|
+
#
|
|
889
|
+
def app_profile_path instance_id, app_profile_id
|
|
890
|
+
Admin::V2::BigtableInstanceAdminClient.app_profile_path project_id, instance_id, app_profile_id
|
|
891
|
+
end
|
|
892
|
+
|
|
893
|
+
##
|
|
894
|
+
# Creates a formatted backup path.
|
|
895
|
+
#
|
|
896
|
+
# @return [String] Formatted backup path
|
|
897
|
+
# `projects/<project>/instances/<instance>/clusters/<cluster>/backups/<backup>`
|
|
898
|
+
#
|
|
899
|
+
def backup_path instance_id, cluster_id, backup_id
|
|
900
|
+
Admin::V2::BigtableTableAdminClient.backup_path project_id, instance_id, cluster_id, backup_id
|
|
901
|
+
end
|
|
902
|
+
|
|
903
|
+
##
|
|
904
|
+
# Inspects the service object.
|
|
905
|
+
# @return [String]
|
|
906
|
+
#
|
|
907
|
+
def inspect
|
|
908
|
+
"#{self.class}(#{@project_id})"
|
|
909
|
+
end
|
|
910
|
+
end
|
|
911
|
+
end
|
|
912
|
+
end
|
|
913
|
+
end
|