google-cloud-bigtable 0.6.2 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (49) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +36 -0
  3. data/CONTRIBUTING.md +1 -1
  4. data/lib/google-cloud-bigtable.rb +19 -21
  5. data/lib/google/cloud/bigtable.rb +11 -17
  6. data/lib/google/cloud/bigtable/app_profile.rb +148 -82
  7. data/lib/google/cloud/bigtable/app_profile/job.rb +5 -8
  8. data/lib/google/cloud/bigtable/app_profile/list.rb +11 -5
  9. data/lib/google/cloud/bigtable/chunk_processor.rb +23 -35
  10. data/lib/google/cloud/bigtable/cluster.rb +38 -11
  11. data/lib/google/cloud/bigtable/cluster/job.rb +3 -7
  12. data/lib/google/cloud/bigtable/cluster/list.rb +20 -18
  13. data/lib/google/cloud/bigtable/column_family.rb +22 -229
  14. data/lib/google/cloud/bigtable/column_family_map.rb +426 -0
  15. data/lib/google/cloud/bigtable/column_range.rb +9 -1
  16. data/lib/google/cloud/bigtable/convert.rb +12 -4
  17. data/lib/google/cloud/bigtable/errors.rb +4 -1
  18. data/lib/google/cloud/bigtable/gc_rule.rb +184 -65
  19. data/lib/google/cloud/bigtable/instance.rb +136 -126
  20. data/lib/google/cloud/bigtable/instance/cluster_map.rb +9 -7
  21. data/lib/google/cloud/bigtable/instance/job.rb +4 -3
  22. data/lib/google/cloud/bigtable/instance/list.rb +14 -9
  23. data/lib/google/cloud/bigtable/longrunning_job.rb +6 -0
  24. data/lib/google/cloud/bigtable/mutation_entry.rb +19 -23
  25. data/lib/google/cloud/bigtable/mutation_operations.rb +82 -29
  26. data/lib/google/cloud/bigtable/policy.rb +9 -5
  27. data/lib/google/cloud/bigtable/project.rb +62 -140
  28. data/lib/google/cloud/bigtable/read_modify_write_rule.rb +9 -4
  29. data/lib/google/cloud/bigtable/read_operations.rb +28 -41
  30. data/lib/google/cloud/bigtable/routing_policy.rb +171 -0
  31. data/lib/google/cloud/bigtable/row.rb +18 -7
  32. data/lib/google/cloud/bigtable/row_filter.rb +49 -20
  33. data/lib/google/cloud/bigtable/row_filter/chain_filter.rb +71 -43
  34. data/lib/google/cloud/bigtable/row_filter/condition_filter.rb +4 -1
  35. data/lib/google/cloud/bigtable/row_filter/interleave_filter.rb +74 -43
  36. data/lib/google/cloud/bigtable/row_filter/simple_filter.rb +22 -7
  37. data/lib/google/cloud/bigtable/row_range.rb +5 -0
  38. data/lib/google/cloud/bigtable/rows_mutator.rb +14 -17
  39. data/lib/google/cloud/bigtable/rows_reader.rb +18 -14
  40. data/lib/google/cloud/bigtable/sample_row_key.rb +5 -2
  41. data/lib/google/cloud/bigtable/service.rb +161 -242
  42. data/lib/google/cloud/bigtable/status.rb +76 -0
  43. data/lib/google/cloud/bigtable/table.rb +141 -236
  44. data/lib/google/cloud/bigtable/table/cluster_state.rb +7 -1
  45. data/lib/google/cloud/bigtable/table/list.rb +14 -7
  46. data/lib/google/cloud/bigtable/value_range.rb +5 -0
  47. data/lib/google/cloud/bigtable/version.rb +1 -1
  48. metadata +27 -25
  49. data/lib/google/cloud/bigtable/table/column_family_map.rb +0 -70
@@ -16,6 +16,7 @@
16
16
  module Google
17
17
  module Cloud
18
18
  module Bigtable
19
+ ##
19
20
  # # RowRange
20
21
  #
21
22
  # Specifies a contiguous range of rows.
@@ -59,6 +60,7 @@ module Google
59
60
  @grpc = Google::Bigtable::V2::RowRange.new
60
61
  end
61
62
 
63
+ ##
62
64
  # Sets a row range with a lower bound.
63
65
  #
64
66
  # @param key [String] Row key. Required.
@@ -91,6 +93,7 @@ module Google
91
93
  self
92
94
  end
93
95
 
96
+ ##
94
97
  # Sets a row range with an upper bound.
95
98
  #
96
99
  # @param key [String] Row key. Required.
@@ -123,6 +126,7 @@ module Google
123
126
  self
124
127
  end
125
128
 
129
+ ##
126
130
  # Sets a row range with inclusive upper and lower bounds.
127
131
  #
128
132
  # @param from_key [String] Inclusive from row key. Required.
@@ -142,6 +146,7 @@ module Google
142
146
  from(from_key).to(to_key, inclusive: true)
143
147
  end
144
148
 
149
+ ##
145
150
  # Sets a row range with an inclusive lower bound and an exclusive upper bound.
146
151
  #
147
152
  # @param from_key [String] Inclusive from row key.
@@ -31,8 +31,8 @@ module Google
31
31
  # Retryable status codes
32
32
  RETRYABLE_CODES = {
33
33
  Google::Rpc::Code::DEADLINE_EXCEEDED => true,
34
- Google::Rpc::Code::ABORTED => true,
35
- Google::Rpc::Code::UNAVAILABLE => true
34
+ Google::Rpc::Code::ABORTED => true,
35
+ Google::Rpc::Code::UNAVAILABLE => true
36
36
  }.freeze
37
37
 
38
38
  # @private
@@ -50,26 +50,25 @@ module Google
50
50
  @entries = entries
51
51
  end
52
52
 
53
+ ##
53
54
  # Applies mutations.
54
55
  #
55
56
  # @return [Array<Google::Bigtable::V2::MutateRowsResponse::Entry>]
56
57
  #
57
58
  def apply_mutations
58
59
  @req_entries = @entries.map(&:to_grpc)
59
- statuses = mutate_rows(@req_entries)
60
+ statuses = mutate_rows @req_entries
60
61
 
61
62
  # Collects retryable mutations indices.
62
- indices = statuses.each_with_object([]) do |e, r|
63
- if @entries[e.index].retryable? && RETRYABLE_CODES[e.status.code]
64
- r << e.index
65
- end
63
+ indices = statuses.each_with_object [] do |e, r|
64
+ r << e.index if @entries[e.index].retryable? && RETRYABLE_CODES[e.status.code]
66
65
  end
67
66
 
68
67
  return statuses if indices.empty?
69
68
 
70
69
  (RETRY_LIMIT - 1).times do
71
70
  break if indices.empty?
72
- indices = retry_entries(statuses, indices)
71
+ indices = retry_entries statuses, indices
73
72
  end
74
73
 
75
74
  statuses
@@ -77,19 +76,16 @@ module Google
77
76
 
78
77
  private
79
78
 
79
+ ##
80
80
  # Mutates rows.
81
81
  #
82
82
  # @param entries [Array<Google::Cloud::Bigtable::MutationEntry>]
83
83
  # @return [Array<Google::Bigtable::V2::MutateRowsResponse::Entry>]
84
84
  #
85
85
  def mutate_rows entries
86
- response = @table.client.mutate_rows(
87
- @table.path,
88
- entries,
89
- app_profile_id: @table.app_profile_id
90
- )
91
- response.each_with_object([]) do |res, statuses|
92
- statuses.concat(res.entries)
86
+ response = @table.client.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
93
89
  end
94
90
  rescue Google::Gax::GaxError => e
95
91
  raise Google::Cloud::Error.from_error(e.cause)
@@ -97,6 +93,7 @@ module Google
97
93
  raise Google::Cloud::Error.from_error(e)
98
94
  end
99
95
 
96
+ ##
100
97
  # Collects failed entries, retries mutation, and updates status.
101
98
  #
102
99
  # @param statuses [Array<Google::Bigtable::V2::MutateRowsResponse::Entry>]
@@ -107,9 +104,9 @@ module Google
107
104
  #
108
105
  def retry_entries statuses, indices
109
106
  entries = indices.map { |i| @req_entries[i] }
110
- retry_statuses = mutate_rows(entries)
107
+ retry_statuses = mutate_rows entries
111
108
 
112
- retry_statuses.each_with_object([]) do |e, next_indices|
109
+ retry_statuses.each_with_object [] do |e, next_indices|
113
110
  next_indices << indices[e.index] if RETRYABLE_CODES[e.status.code]
114
111
  statuses[indices[e.index]].status = e.status
115
112
  end
@@ -56,6 +56,7 @@ module Google
56
56
  @retry_count = 0
57
57
  end
58
58
 
59
+ ##
59
60
  # Read rows
60
61
  #
61
62
  # @param rows [Google::Bigtable::V2::RowSet]
@@ -72,22 +73,19 @@ module Google
72
73
  # The default (zero) is to return all results.
73
74
  # @return [:yields: row]
74
75
  # Array of row or yield block for each processed row.
75
-
76
- def read \
77
- rows: nil,
78
- filter: nil,
79
- rows_limit: nil
76
+ #
77
+ def read rows: nil, filter: nil, rows_limit: nil
80
78
  response = @table.client.read_rows(
81
79
  @table.path,
82
- rows: rows,
83
- filter: filter,
84
- rows_limit: rows_limit,
80
+ rows: rows,
81
+ filter: filter,
82
+ rows_limit: rows_limit,
85
83
  app_profile_id: @table.app_profile_id
86
84
  )
87
85
  response.each do |res|
88
86
  res.chunks.each do |chunk|
89
87
  @retry_count = 0
90
- row = @chunk_processor.process(chunk)
88
+ row = @chunk_processor.process chunk
91
89
  next if row.nil?
92
90
  yield row
93
91
  @rows_count += 1
@@ -97,14 +95,16 @@ module Google
97
95
  @chunk_processor.validate_last_row_complete
98
96
  end
99
97
 
98
+ ##
100
99
  # Last read row key.
101
100
  #
102
101
  # @return [String]
103
-
102
+ #
104
103
  def last_key
105
104
  @chunk_processor.last_key
106
105
  end
107
106
 
107
+ ##
108
108
  # Calucates and returns the read rows limit and row set based on last read key.
109
109
  #
110
110
  # @param rows_limit [Integer]
@@ -116,7 +116,7 @@ module Google
116
116
  # A hash of the same form as `Google::Bigtable::V2::RowSet`
117
117
  # can also be provided.
118
118
  # @return [Integer, Google::Bigtable::V2::RowSet]
119
-
119
+ #
120
120
  def retry_options rows_limit, row_set
121
121
  return [rows_limit, row_set] unless last_key
122
122
 
@@ -129,14 +129,14 @@ module Google
129
129
  delete_indexes = []
130
130
 
131
131
  row_set.row_ranges.each_with_index do |range, i|
132
- if end_key_read?(range)
132
+ if end_key_read? range
133
133
  delete_indexes << i
134
- elsif start_key_read?(range)
134
+ elsif start_key_read? range
135
135
  range.start_key_open = last_key
136
136
  end
137
137
  end
138
138
 
139
- delete_indexes.each { |i| row_set.row_ranges.delete_at(i) }
139
+ delete_indexes.each { |i| row_set.row_ranges.delete_at i }
140
140
  end
141
141
 
142
142
  if row_set.row_ranges.empty?
@@ -151,15 +151,18 @@ module Google
151
151
  [rows_limit, row_set]
152
152
  end
153
153
 
154
+ ##
154
155
  # Checks if a read operation is retryable.
155
156
  #
156
157
  # @return [Boolean]
158
+ #
157
159
  def retryable?
158
160
  @retry_count < RowsReader::RETRY_LIMIT
159
161
  end
160
162
 
161
163
  private
162
164
 
165
+ ##
163
166
  # Checks if the start key was already read for the range.
164
167
  #
165
168
  # @param range [Google::Bigtable::V2::RowRange]
@@ -175,6 +178,7 @@ module Google
175
178
  start_key.empty? || last_key >= start_key
176
179
  end
177
180
 
181
+ ##
178
182
  # Checks if the end key was already read for the range.
179
183
  #
180
184
  # @param range [Google::Bigtable::V2::RowRange]
@@ -18,6 +18,7 @@
18
18
  module Google
19
19
  module Cloud
20
20
  module Bigtable
21
+ ##
21
22
  # # SampleRowKey
22
23
  #
23
24
  # Sample row key with byte offset.
@@ -37,7 +38,7 @@ module Google
37
38
  # `offset_bytes` fields.
38
39
  #
39
40
  # @example
40
- # require "google/cloud"
41
+ # require "google/cloud/bigtable"
41
42
  #
42
43
  # bigtable = Google::Cloud::Bigtable.new
43
44
  #
@@ -48,9 +49,11 @@ module Google
48
49
  # end
49
50
  #
50
51
  class SampleRowKey
52
+ ##
51
53
  # @return [String] Sample row key.
52
54
  attr_reader :key
53
55
 
56
+ ##
54
57
  # @return [Integer] Row offset in bytes.
55
58
  attr_reader :offset
56
59
 
@@ -74,7 +77,7 @@ module Google
74
77
  # @return [Google::Cloud::Bigtable::SampleRowKey]
75
78
  #
76
79
  def self.from_grpc grpc
77
- new(grpc.row_key, grpc.offset_bytes)
80
+ new grpc.row_key, grpc.offset_bytes
78
81
  end
79
82
  end
80
83
  end
@@ -35,30 +35,25 @@ module Google
35
35
  # Creates a new Service instance.
36
36
  #
37
37
  # @param project_id [String] Project identifier
38
- # @param credentials [Google::Auth::Credentials, String, Hash, GRPC::Core::Channel, GRPC::Core::ChannelCredentials, Proc]
39
- # The means for authenticating requests made by the client. This parameter can
40
- # be one of the following types.
41
- # `Google::Auth::Credentials` uses the properties of its represented keyfile for
42
- # authenticating requests made by this client.
43
- # `String` will be treated as the path to the keyfile to use to construct
44
- # credentials for this client.
45
- # `Hash` will be treated as the contents of a keyfile to use to construct
46
- # credentials for this client.
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.
47
45
  # `GRPC::Core::Channel` will be used to make calls through.
48
- # `GRPC::Core::ChannelCredentials` will be used to set up the gRPC client. The channel credentials
49
- # should already be composed with a `GRPC::Core::CallCredentials` object.
50
- # `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.
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.
52
50
  # @param timeout [Integer]
53
51
  # The default timeout, in seconds, for calls made through this client.
54
52
  # @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, host: nil, timeout: nil,
61
- client_config: nil
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
62
57
  @project_id = project_id
63
58
  @credentials = credentials
64
59
  @host = host
@@ -72,74 +67,73 @@ module Google
72
67
  end
73
68
 
74
69
  def chan_args
75
- { "grpc.max_send_message_length" => -1,
76
- "grpc.max_receive_message_length" => -1,
70
+ { "grpc.max_send_message_length" => -1,
71
+ "grpc.max_receive_message_length" => -1,
77
72
  "grpc.service_config_disable_resolution" => 1 }
78
73
  end
79
74
 
80
75
  def chan_creds
81
76
  return credentials if insecure?
82
77
  require "grpc"
83
- GRPC::Core::ChannelCredentials.new.compose \
84
- GRPC::Core::CallCredentials.new credentials.client.updater_proc
78
+ GRPC::Core::ChannelCredentials.new.compose GRPC::Core::CallCredentials.new credentials.client.updater_proc
85
79
  end
86
80
 
81
+ ##
87
82
  # Creates or returns an instance of an instance admin client.
88
83
  #
89
84
  # @return [Google::Cloud::Bigtable::Admin::V2::BigtableInstanceAdminClient]
90
-
85
+ #
91
86
  def instances
92
- @instances ||= begin
93
- instances_channel = channel(
94
- Admin::V2::BigtableInstanceAdminClient::SERVICE_ADDRESS
95
- )
96
- Admin::V2::BigtableInstanceAdminClient.new(
97
- credentials: instances_channel,
98
- timeout: timeout,
99
- client_config: client_config,
100
- lib_name: "gccl",
101
- lib_version: Google::Cloud::Bigtable::VERSION
102
- )
103
- end
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
+ )
104
95
  end
96
+ attr_accessor :mocked_instances
105
97
 
98
+ ##
106
99
  # Creates or returns an instance of a table admin client.
107
100
  #
108
101
  # @return [Google::Cloud::Bigtable::Admin::V2::BigtableTableAdminClient]
109
-
102
+ #
110
103
  def tables
111
- @tables ||= begin
112
- tables_channel = channel(
113
- Admin::V2::BigtableTableAdminClient::SERVICE_ADDRESS
114
- )
115
- Admin::V2::BigtableTableAdminClient.new(
116
- credentials: tables_channel,
117
- timeout: timeout,
118
- client_config: client_config,
119
- lib_name: "gccl",
120
- lib_version: Google::Cloud::Bigtable::VERSION
121
- )
122
- end
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
+ )
123
112
  end
113
+ attr_accessor :mocked_tables
124
114
 
115
+ ##
125
116
  # Creates an instance of a data client.
126
117
  #
127
118
  # @return [Google::Cloud::Bigtable::V2::BigtableClient]
128
-
119
+ #
129
120
  def client
130
- @client ||= \
131
- V2::BigtableClient.new(
132
- credentials: channel(V2::BigtableClient::SERVICE_ADDRESS),
133
- timeout: timeout,
134
- client_config: client_config,
135
- lib_name: "gccl",
136
- lib_version: Google::Cloud::Bigtable::VERSION
137
- )
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
+ )
138
129
  end
130
+ attr_accessor :mocked_client
139
131
 
140
132
  def insecure?
141
133
  credentials == :this_channel_is_insecure
142
134
  end
135
+
136
+ ##
143
137
  # Creates an instance within a project.
144
138
  #
145
139
  # @param instance_id [String]
@@ -153,50 +147,40 @@ module Google
153
147
  # +projects/myproject/instances/myinstance/clusters/mycluster+.
154
148
  # Alternatively, provide a hash in the form of `Google::Bigtable::Admin::V2::Cluster`
155
149
  # @return [Google::Gax::Operation]
156
-
157
- def create_instance \
158
- instance_id,
159
- instance,
160
- clusters
150
+ #
151
+ def create_instance instance_id, instance, clusters
161
152
  execute do
162
- instances.create_instance(
163
- project_path,
164
- instance_id,
165
- instance,
166
- clusters
167
- )
153
+ instances.create_instance project_path, instance_id, instance, clusters
168
154
  end
169
155
  end
170
156
 
157
+ ##
171
158
  # Lists the instances in a project.
172
159
  #
173
160
  # @param token [String]
174
161
  # The value of +next_page_token+ returned by a previous call.
175
162
  # @return [Google::Bigtable::Admin::V2::ListInstancesResponse]
176
-
163
+ #
177
164
  def list_instances token: nil
178
165
  execute do
179
- instances.list_instances(
180
- project_path,
181
- page_token: token
182
- )
166
+ instances.list_instances project_path, page_token: token
183
167
  end
184
168
  end
185
169
 
170
+ ##
186
171
  # Gets information about an instance.
187
172
  #
188
173
  # @param instance_id [String]
189
174
  # Unique ID of the requested instance.
190
175
  # @return [Google::Bigtable::Admin::V2::Instance]
191
-
176
+ #
192
177
  def get_instance instance_id
193
178
  execute do
194
- instances.get_instance(
195
- instance_path(instance_id)
196
- )
179
+ instances.get_instance instance_path(instance_id)
197
180
  end
198
181
  end
199
182
 
183
+ ##
200
184
  # Partially updates an instance.
201
185
  #
202
186
  # @param instance [Google::Bigtable::Admin::V2::Instance | Hash]
@@ -207,18 +191,19 @@ module Google
207
191
  # Must be explicitly set.
208
192
  # Alternatively, provide a hash in the form of `Google::Protobuf::FieldMask`.
209
193
  # @return [Google::Gax::Operation]
210
-
194
+ #
211
195
  def partial_update_instance instance, update_mask
212
196
  execute do
213
- instances.partial_update_instance(instance, update_mask)
197
+ instances.partial_update_instance instance, update_mask
214
198
  end
215
199
  end
216
200
 
201
+ ##
217
202
  # Deletes an instance from a project.
218
203
  #
219
204
  # @param instance_id [String]
220
205
  # Unique ID of the instance to be deleted.
221
-
206
+ #
222
207
  def delete_instance instance_id
223
208
  execute do
224
209
  instances.delete_instance(
@@ -227,6 +212,7 @@ module Google
227
212
  end
228
213
  end
229
214
 
215
+ ##
230
216
  # Creates a cluster within an instance.
231
217
  #
232
218
  # @param instance_id [String]
@@ -238,21 +224,16 @@ module Google
238
224
  # Alternatively, provide a hash in the form of `Google::Bigtable::Admin::V2::Cluster`
239
225
  #
240
226
  # @return [Google::Gax::Operation]
241
-
227
+ #
242
228
  def create_cluster instance_id, cluster_id, cluster
243
- unless cluster.location == ""
244
- cluster.location = location_path(cluster.location)
245
- end
229
+ cluster.location = location_path cluster.location unless cluster.location == ""
246
230
 
247
231
  execute do
248
- instances.create_cluster(
249
- instance_path(instance_id),
250
- cluster_id,
251
- cluster
252
- )
232
+ instances.create_cluster instance_path(instance_id), cluster_id, cluster
253
233
  end
254
234
  end
255
235
 
236
+ ##
256
237
  # Lists information about clusters in an instance.
257
238
  #
258
239
  # @param instance_id [String]
@@ -260,16 +241,14 @@ module Google
260
241
  # @param token [String]
261
242
  # The value of +next_page_token+ returned by a previous call.
262
243
  # @return [Google::Bigtable::Admin::V2::ListClustersResponse]
263
-
244
+ #
264
245
  def list_clusters instance_id, token: nil
265
246
  execute do
266
- instances.list_clusters(
267
- instance_path(instance_id),
268
- page_token: token
269
- )
247
+ instances.list_clusters instance_path(instance_id), page_token: token
270
248
  end
271
249
  end
272
250
 
251
+ ##
273
252
  # Gets information about a cluster.
274
253
  #
275
254
  # @param instance_id [String]
@@ -277,15 +256,14 @@ module Google
277
256
  # @param cluster_id [String]
278
257
  # Unique ID of the requested cluster.
279
258
  # @return [Google::Bigtable::Admin::V2::Cluster]
280
-
259
+ #
281
260
  def get_cluster instance_id, cluster_id
282
261
  execute do
283
- instances.get_cluster(
284
- cluster_path(instance_id, cluster_id)
285
- )
262
+ instances.get_cluster cluster_path(instance_id, cluster_id)
286
263
  end
287
264
  end
288
265
 
266
+ ##
289
267
  # Updates a cluster within an instance.
290
268
  #
291
269
  # @param instance_id [String]
@@ -301,32 +279,28 @@ module Google
301
279
  # The number of nodes allocated to this cluster. More nodes enable higher
302
280
  # throughput and more consistent performance.
303
281
  # @return [Google::Gax::Operation]
304
-
282
+ #
305
283
  def update_cluster instance_id, cluster_id, location, serve_nodes
306
284
  execute do
307
- instances.update_cluster(
308
- cluster_path(instance_id, cluster_id),
309
- location,
310
- serve_nodes
311
- )
285
+ instances.update_cluster cluster_path(instance_id, cluster_id), location, serve_nodes
312
286
  end
313
287
  end
314
288
 
289
+ ##
315
290
  # Deletes a cluster from an instance.
316
291
  #
317
292
  # @param instance_id [String]
318
293
  # Unique ID of the instance the cluster is in.
319
294
  # @param cluster_id [String]
320
295
  # Unique ID of the cluster to be deleted.
321
-
296
+ #
322
297
  def delete_cluster instance_id, cluster_id
323
298
  execute do
324
- instances.delete_cluster(
325
- cluster_path(instance_id, cluster_id)
326
- )
299
+ instances.delete_cluster cluster_path(instance_id, cluster_id)
327
300
  end
328
301
  end
329
302
 
303
+ ##
330
304
  # Creates a new table in the specified instance.
331
305
  # Optionally, creates the table with a full set of initial column families.
332
306
  #
@@ -357,26 +331,16 @@ module Google
357
331
  # Alternatively, provide a hash in the form of
358
332
  # `Google::Bigtable::Admin::V2::CreateTableRequest::Split`
359
333
  # @return [Google::Bigtable::Admin::V2::Table]
360
-
361
- def create_table \
362
- instance_id,
363
- table_id,
364
- table,
365
- initial_splits: nil
366
- if initial_splits
367
- initial_splits = initial_splits.map { |key| { key: key } }
368
- end
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
369
337
 
370
338
  execute do
371
- tables.create_table(
372
- instance_path(instance_id),
373
- table_id,
374
- table,
375
- initial_splits: initial_splits
376
- )
339
+ tables.create_table instance_path(instance_id), table_id, table, initial_splits: initial_splits
377
340
  end
378
341
  end
379
342
 
343
+ ##
380
344
  # Lists all tables in an instance.
381
345
  #
382
346
  # @param instance_id [String]
@@ -388,16 +352,14 @@ module Google
388
352
  # An enumerable of Google::Bigtable::Admin::V2::Table instances.
389
353
  # See Google::Gax::PagedEnumerable documentation for other
390
354
  # operations such as per-page iteration or access to the response.
391
-
355
+ #
392
356
  def list_tables instance_id, view: nil
393
357
  execute do
394
- tables.list_tables(
395
- instance_path(instance_id),
396
- view: view
397
- )
358
+ tables.list_tables instance_path(instance_id), view: view
398
359
  end
399
360
  end
400
361
 
362
+ ##
401
363
  # Gets metadata about the specified table.
402
364
  #
403
365
  # @param instance_id [String]
@@ -408,31 +370,28 @@ module Google
408
370
  # View to be applied to the returned table's fields.
409
371
  # Defaults to +SCHEMA_VIEW+ if unspecified.
410
372
  # @return [Google::Bigtable::Admin::V2::Table]
411
-
373
+ #
412
374
  def get_table instance_id, table_id, view: nil
413
375
  execute do
414
- tables.get_table(
415
- table_path(instance_id, table_id),
416
- view: view
417
- )
376
+ tables.get_table table_path(instance_id, table_id), view: view
418
377
  end
419
378
  end
420
379
 
380
+ ##
421
381
  # Permanently deletes a table and all of its data.
422
382
  #
423
383
  # @param instance_id [String]
424
384
  # Unique ID of the instance the table is in.
425
385
  # @param table_id [String]
426
386
  # Unique ID of the table to be deleted.
427
-
387
+ #
428
388
  def delete_table instance_id, table_id
429
389
  execute do
430
- tables.delete_table(
431
- table_path(instance_id, table_id)
432
- )
390
+ tables.delete_table table_path(instance_id, table_id)
433
391
  end
434
392
  end
435
393
 
394
+ ##
436
395
  # Performs a series of column family modifications on the specified table.
437
396
  # Either all or none of the modifications will occur before this method
438
397
  # returns. Data requests received prior to completion of this method may reach a table
@@ -450,16 +409,14 @@ module Google
450
409
  # Alternatively, provide a hash in the form of
451
410
  # `Google::Bigtable::Admin::V2::ModifyColumnFamiliesRequest::Modification`.
452
411
  # @return [Google::Bigtable::Admin::V2::Table]
453
-
412
+ #
454
413
  def modify_column_families instance_id, table_id, modifications
455
414
  execute do
456
- tables.modify_column_families(
457
- table_path(instance_id, table_id),
458
- modifications
459
- )
415
+ tables.modify_column_families table_path(instance_id, table_id), modifications
460
416
  end
461
417
  end
462
418
 
419
+ ##
463
420
  # Generates a consistency token for a table.
464
421
  # The consistency token can be be used in CheckConsistency to check whether
465
422
  # mutations to the table that finished before this call started have been replicated.
@@ -470,15 +427,14 @@ module Google
470
427
  # @param table_id [String]
471
428
  # Unique ID of the table the consistency token is for.
472
429
  # @return [Google::Bigtable::Admin::V2::GenerateConsistencyTokenResponse]
473
-
430
+ #
474
431
  def generate_consistency_token instance_id, table_id
475
432
  execute do
476
- tables.generate_consistency_token(
477
- table_path(instance_id, table_id)
478
- )
433
+ tables.generate_consistency_token table_path(instance_id, table_id)
479
434
  end
480
435
  end
481
436
 
437
+ ##
482
438
  # Checks replication consistency based on a consistency token.
483
439
  # Determines if replication has caught up, based on the conditions in the token
484
440
  # and the check request.
@@ -490,16 +446,14 @@ module Google
490
446
  # @param token [String] Consistency token
491
447
  # The token created for the table using GenerateConsistencyToken.
492
448
  # @return [Google::Bigtable::Admin::V2::CheckConsistencyResponse]
493
-
449
+ #
494
450
  def check_consistency instance_id, table_id, token
495
451
  execute do
496
- tables.check_consistency(
497
- table_path(instance_id, table_id),
498
- token
499
- )
452
+ tables.check_consistency table_path(instance_id, table_id), token
500
453
  end
501
454
  end
502
455
 
456
+ ##
503
457
  # Permanently deletes a row range from a table. The request can
504
458
  # specify whether to delete all rows in a table or only rows that match a
505
459
  # particular row key prefix.
@@ -515,13 +469,8 @@ module Google
515
469
  # If true, delete all rows in the table. Setting this to false is a no-op.
516
470
  # @param timeout [Integer]
517
471
  # Sets the API call timeout if deadline exceeds exception.
518
-
519
- def drop_row_range \
520
- instance_id,
521
- table_id,
522
- row_key_prefix: nil,
523
- delete_all_data_from_table: nil,
524
- timeout: nil
472
+ #
473
+ def drop_row_range instance_id, table_id, row_key_prefix: nil, delete_all_data_from_table: nil, timeout: nil
525
474
  call_options = nil
526
475
 
527
476
  # Pass a timeout with a larger value if the drop operation throws
@@ -531,21 +480,20 @@ module Google
531
480
  [],
532
481
  Google::Gax::BackoffSettings.new(0, 0, 0, timeout * 1000, 0, 0, 0)
533
482
  )
534
- call_options = Google::Gax::CallOptions.new(
535
- retry_options: retry_options
536
- )
483
+ call_options = Google::Gax::CallOptions.new retry_options: retry_options
537
484
  end
538
485
 
539
486
  execute do
540
487
  tables.drop_row_range(
541
488
  table_path(instance_id, table_id),
542
- row_key_prefix: row_key_prefix,
489
+ row_key_prefix: row_key_prefix,
543
490
  delete_all_data_from_table: delete_all_data_from_table,
544
- options: call_options
491
+ options: call_options
545
492
  )
546
493
  end
547
494
  end
548
495
 
496
+ ##
549
497
  # Creates an app profile within an instance.
550
498
  #
551
499
  # @param instance_id [String]
@@ -559,12 +507,8 @@ module Google
559
507
  # @param ignore_warnings [Boolean]
560
508
  # If true, ignore safety checks when creating the app profile.
561
509
  # @return [Google::Bigtable::Admin::V2::AppProfile]
562
-
563
- def create_app_profile \
564
- instance_id,
565
- app_profile_id,
566
- app_profile,
567
- ignore_warnings: nil
510
+ #
511
+ def create_app_profile instance_id, app_profile_id, app_profile, ignore_warnings: nil
568
512
  execute do
569
513
  instances.create_app_profile(
570
514
  instance_path(instance_id),
@@ -575,6 +519,7 @@ module Google
575
519
  end
576
520
  end
577
521
 
522
+ ##
578
523
  # Gets information about an app profile.
579
524
  #
580
525
  # @param instance_id [String]
@@ -582,15 +527,14 @@ module Google
582
527
  # @param app_profile_id [String]
583
528
  # Unique ID of the requested app profile.
584
529
  # @return [Google::Bigtable::Admin::V2::AppProfile]
585
-
530
+ #
586
531
  def get_app_profile instance_id, app_profile_id
587
532
  execute do
588
- instances.get_app_profile(
589
- app_profile_path(instance_id, app_profile_id)
590
- )
533
+ instances.get_app_profile app_profile_path(instance_id, app_profile_id)
591
534
  end
592
535
  end
593
536
 
537
+ ##
594
538
  # Lists information about app profiles in an instance.
595
539
  #
596
540
  # @param instance_id [String]
@@ -600,14 +544,14 @@ module Google
600
544
  # See Google::Gax::PagedEnumerable documentation for other
601
545
  # operations such as per-page iteration or access to the response
602
546
  # object.
547
+ #
603
548
  def list_app_profiles instance_id
604
549
  execute do
605
- instances.list_app_profiles(
606
- instance_path(instance_id)
607
- )
550
+ instances.list_app_profiles instance_path(instance_id)
608
551
  end
609
552
  end
610
553
 
554
+ ##
611
555
  # Updates an app profile within an instance.
612
556
  #
613
557
  # @param app_profile [Google::Bigtable::Admin::V2::AppProfile | Hash]
@@ -621,17 +565,14 @@ module Google
621
565
  # @param ignore_warnings [Boolean]
622
566
  # If true, ignore safety checks when updating the app profile.
623
567
  # @return [Google::Longrunning::Operation]
624
-
568
+ #
625
569
  def update_app_profile app_profile, update_mask, ignore_warnings: nil
626
570
  execute do
627
- instances.update_app_profile(
628
- app_profile,
629
- update_mask,
630
- ignore_warnings: ignore_warnings
631
- )
571
+ instances.update_app_profile app_profile, update_mask, ignore_warnings: ignore_warnings
632
572
  end
633
573
  end
634
574
 
575
+ ##
635
576
  # Deletes an app profile from an instance.
636
577
  #
637
578
  # @param instance_id [String]
@@ -640,31 +581,28 @@ module Google
640
581
  # Unique ID of the app profile to be deleted.
641
582
  # @param ignore_warnings [Boolean]
642
583
  # If true, ignore safety checks when deleting the app profile.
643
-
584
+ #
644
585
  def delete_app_profile instance_id, app_profile_id, ignore_warnings: nil
645
586
  execute do
646
- instances.delete_app_profile(
647
- app_profile_path(instance_id, app_profile_id),
648
- ignore_warnings
649
- )
587
+ instances.delete_app_profile app_profile_path(instance_id, app_profile_id), ignore_warnings
650
588
  end
651
589
  end
652
590
 
591
+ ##
653
592
  # Gets the access control policy for an instance resource. Returns an empty
654
593
  # policy if an instance exists but does not have a policy set.
655
594
  #
656
595
  # @param instance_id [String]
657
596
  # Unique ID of the instance for which the policy is being requested.
658
597
  # @return [Google::Iam::V1::Policy]
659
-
598
+ #
660
599
  def get_instance_policy instance_id
661
600
  execute do
662
- instances.get_iam_policy(
663
- instance_path(instance_id)
664
- )
601
+ instances.get_iam_policy instance_path(instance_id)
665
602
  end
666
603
  end
667
604
 
605
+ ##
668
606
  # Sets the access control policy on an instance resource. Replaces any
669
607
  # existing policy.
670
608
  #
@@ -677,16 +615,14 @@ module Google
677
615
  # might reject an empty policy.
678
616
  # Alternatively, provide a hash similar to `Google::Iam::V1::Policy`.
679
617
  # @return [Google::Iam::V1::Policy]
680
-
618
+ #
681
619
  def set_instance_policy instance_id, policy
682
620
  execute do
683
- instances.set_iam_policy(
684
- instance_path(instance_id),
685
- policy
686
- )
621
+ instances.set_iam_policy instance_path(instance_id), policy
687
622
  end
688
623
  end
689
624
 
625
+ ##
690
626
  # Returns permissions that the caller has for the specified instance resource.
691
627
  #
692
628
  # @param instance_id [String]
@@ -697,20 +633,18 @@ module Google
697
633
  # information see
698
634
  # [IAM Overview](https://cloud.google.com/iam/docs/overview#permissions).
699
635
  # @return [Google::Iam::V1::TestIamPermissionsResponse]
700
-
636
+ #
701
637
  def test_instance_permissions instance_id, permissions
702
638
  execute do
703
- instances.test_iam_permissions(
704
- instance_path(instance_id),
705
- permissions
706
- )
639
+ instances.test_iam_permissions instance_path(instance_id), permissions
707
640
  end
708
641
  end
709
642
 
643
+ ##
710
644
  # Executes the API call and wrap errors to {Google::Cloud::Error}.
711
645
  #
712
646
  # @raise [Google::Cloud::Error]
713
-
647
+ #
714
648
  def execute
715
649
  yield
716
650
  rescue Google::Gax::GaxError => e
@@ -719,30 +653,30 @@ module Google
719
653
  raise Google::Cloud::Error.from_error(e)
720
654
  end
721
655
 
656
+ ##
722
657
  # Creates a formatted project path.
723
658
  #
724
659
  # @return [String]
725
660
  # Formatted project path
726
661
  # +projects/<project>+
727
-
662
+ #
728
663
  def project_path
729
- Admin::V2::BigtableInstanceAdminClient.project_path(project_id)
664
+ Admin::V2::BigtableInstanceAdminClient.project_path project_id
730
665
  end
731
666
 
667
+ ##
732
668
  # Creates a formatted instance path.
733
669
  #
734
670
  # @param instance_id [String]
735
671
  # @return [String]
736
672
  # Formatted instance path
737
673
  # +projects/<project>/instances/[a-z][a-z0-9\\-]+[a-z0-9]+.
738
-
674
+ #
739
675
  def instance_path instance_id
740
- Admin::V2::BigtableInstanceAdminClient.instance_path(
741
- project_id,
742
- instance_id
743
- )
676
+ Admin::V2::BigtableInstanceAdminClient.instance_path project_id, instance_id
744
677
  end
745
678
 
679
+ ##
746
680
  # Creates a formatted cluster path.
747
681
  #
748
682
  # @param instance_id [String]
@@ -750,15 +684,12 @@ module Google
750
684
  # @return [String]
751
685
  # Formatted cluster path
752
686
  # +projects/<project>/instances/<instance>/clusters/<cluster>+.
753
-
687
+ #
754
688
  def cluster_path instance_id, cluster_id
755
- Admin::V2::BigtableInstanceAdminClient.cluster_path(
756
- project_id,
757
- instance_id,
758
- cluster_id
759
- )
689
+ Admin::V2::BigtableInstanceAdminClient.cluster_path project_id, instance_id, cluster_id
760
690
  end
761
691
 
692
+ ##
762
693
  # Creates a formatted location path.
763
694
  #
764
695
  # @param location [String]
@@ -766,29 +697,24 @@ module Google
766
697
  # @return [String]
767
698
  # Formatted location path
768
699
  # +projects/<project_id>/locations/<location>+.
769
-
700
+ #
770
701
  def location_path location
771
- Admin::V2::BigtableInstanceAdminClient.location_path(
772
- project_id,
773
- location
774
- )
702
+ Admin::V2::BigtableInstanceAdminClient.location_path project_id, location
775
703
  end
776
704
 
705
+ ##
777
706
  # Creates a formatted table path.
778
707
  #
779
708
  # @param table_id [String]
780
709
  # @return [String]
781
710
  # Formatted table path
782
711
  # +projects/<project>/instances/<instance>/tables/<table>+
783
-
712
+ #
784
713
  def table_path instance_id, table_id
785
- Admin::V2::BigtableTableAdminClient.table_path(
786
- project_id,
787
- instance_id,
788
- table_id
789
- )
714
+ Admin::V2::BigtableTableAdminClient.table_path project_id, instance_id, table_id
790
715
  end
791
716
 
717
+ ##
792
718
  # Creates a formatted snapshot path.
793
719
  #
794
720
  # @param instance_id [String]
@@ -797,16 +723,12 @@ module Google
797
723
  # @return [String]
798
724
  # Formatted snapshot path
799
725
  # +projects/<project>/instances/<instance>/clusters/<cluster>/snapshots/<snapshot>+
800
-
726
+ #
801
727
  def snapshot_path instance_id, cluster_id, snapshot_id
802
- Admin::V2::BigtableTableAdminClient.snapshot_path(
803
- project_id,
804
- instance_id,
805
- cluster_id,
806
- snapshot_id
807
- )
728
+ Admin::V2::BigtableTableAdminClient.snapshot_path project_id, instance_id, cluster_id, snapshot_id
808
729
  end
809
730
 
731
+ ##
810
732
  # Creates a formatted app profile path.
811
733
  #
812
734
  # @param instance_id [String]
@@ -814,18 +736,15 @@ module Google
814
736
  # @return [String]
815
737
  # Formatted snapshot path
816
738
  # +projects/<project>/instances/<instance>/appProfiles/<app_profile>+
817
-
739
+ #
818
740
  def app_profile_path instance_id, app_profile_id
819
- Admin::V2::BigtableInstanceAdminClient.app_profile_path(
820
- project_id,
821
- instance_id,
822
- app_profile_id
823
- )
741
+ Admin::V2::BigtableInstanceAdminClient.app_profile_path project_id, instance_id, app_profile_id
824
742
  end
825
743
 
744
+ ##
826
745
  # Inspects the service object.
827
746
  # @return [String]
828
-
747
+ #
829
748
  def inspect
830
749
  "#{self.class}(#{@project_id})"
831
750
  end