google-cloud-bigtable 0.1.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.
Files changed (88) hide show
  1. checksums.yaml +7 -0
  2. data/.yardopts +10 -0
  3. data/LICENSE +201 -0
  4. data/README.md +65 -0
  5. data/lib/google/bigtable/admin/v2/bigtable_instance_admin_pb.rb +139 -0
  6. data/lib/google/bigtable/admin/v2/bigtable_instance_admin_services_pb.rb +85 -0
  7. data/lib/google/bigtable/admin/v2/bigtable_table_admin_pb.rb +137 -0
  8. data/lib/google/bigtable/admin/v2/bigtable_table_admin_services_pb.rb +117 -0
  9. data/lib/google/bigtable/admin/v2/common_pb.rb +24 -0
  10. data/lib/google/bigtable/admin/v2/instance_pb.rb +72 -0
  11. data/lib/google/bigtable/admin/v2/table_pb.rb +88 -0
  12. data/lib/google/bigtable/v2/bigtable_pb.rb +109 -0
  13. data/lib/google/bigtable/v2/bigtable_services_pb.rb +67 -0
  14. data/lib/google/bigtable/v2/data_pb.rb +155 -0
  15. data/lib/google/cloud/bigtable/admin/credentials.rb +26 -0
  16. data/lib/google/cloud/bigtable/admin/v2/bigtable_instance_admin_client.rb +1417 -0
  17. data/lib/google/cloud/bigtable/admin/v2/bigtable_instance_admin_client_config.json +123 -0
  18. data/lib/google/cloud/bigtable/admin/v2/bigtable_table_admin_client.rb +1079 -0
  19. data/lib/google/cloud/bigtable/admin/v2/bigtable_table_admin_client_config.json +109 -0
  20. data/lib/google/cloud/bigtable/admin/v2/credentials.rb +50 -0
  21. data/lib/google/cloud/bigtable/admin/v2/doc/google/bigtable/admin/v2/bigtable_instance_admin.rb +279 -0
  22. data/lib/google/cloud/bigtable/admin/v2/doc/google/bigtable/admin/v2/bigtable_table_admin.rb +353 -0
  23. data/lib/google/cloud/bigtable/admin/v2/doc/google/bigtable/admin/v2/instance.rb +194 -0
  24. data/lib/google/cloud/bigtable/admin/v2/doc/google/bigtable/admin/v2/table.rb +209 -0
  25. data/lib/google/cloud/bigtable/admin/v2/doc/google/iam/v1/iam_policy.rb +62 -0
  26. data/lib/google/cloud/bigtable/admin/v2/doc/google/iam/v1/policy.rb +127 -0
  27. data/lib/google/cloud/bigtable/admin/v2/doc/google/longrunning/operations.rb +92 -0
  28. data/lib/google/cloud/bigtable/admin/v2/doc/google/protobuf/any.rb +124 -0
  29. data/lib/google/cloud/bigtable/admin/v2/doc/google/protobuf/duration.rb +90 -0
  30. data/lib/google/cloud/bigtable/admin/v2/doc/google/protobuf/empty.rb +28 -0
  31. data/lib/google/cloud/bigtable/admin/v2/doc/google/protobuf/field_mask.rb +223 -0
  32. data/lib/google/cloud/bigtable/admin/v2/doc/google/protobuf/timestamp.rb +106 -0
  33. data/lib/google/cloud/bigtable/admin/v2/doc/google/rpc/status.rb +83 -0
  34. data/lib/google/cloud/bigtable/admin/v2.rb +200 -0
  35. data/lib/google/cloud/bigtable/admin.rb +196 -0
  36. data/lib/google/cloud/bigtable/app_profile/job.rb +102 -0
  37. data/lib/google/cloud/bigtable/app_profile/list.rb +159 -0
  38. data/lib/google/cloud/bigtable/app_profile.rb +373 -0
  39. data/lib/google/cloud/bigtable/chunk_processor.rb +253 -0
  40. data/lib/google/cloud/bigtable/cluster/job.rb +92 -0
  41. data/lib/google/cloud/bigtable/cluster/list.rb +169 -0
  42. data/lib/google/cloud/bigtable/cluster.rb +264 -0
  43. data/lib/google/cloud/bigtable/column_family.rb +280 -0
  44. data/lib/google/cloud/bigtable/column_range.rb +186 -0
  45. data/lib/google/cloud/bigtable/convert.rb +75 -0
  46. data/lib/google/cloud/bigtable/credentials.rb +24 -0
  47. data/lib/google/cloud/bigtable/errors.rb +35 -0
  48. data/lib/google/cloud/bigtable/gc_rule.rb +215 -0
  49. data/lib/google/cloud/bigtable/instance/cluster_map.rb +70 -0
  50. data/lib/google/cloud/bigtable/instance/job.rb +97 -0
  51. data/lib/google/cloud/bigtable/instance/list.rb +159 -0
  52. data/lib/google/cloud/bigtable/instance.rb +921 -0
  53. data/lib/google/cloud/bigtable/longrunning_job.rb +105 -0
  54. data/lib/google/cloud/bigtable/mutation_entry.rb +244 -0
  55. data/lib/google/cloud/bigtable/mutation_operations.rb +338 -0
  56. data/lib/google/cloud/bigtable/policy.rb +163 -0
  57. data/lib/google/cloud/bigtable/project.rb +580 -0
  58. data/lib/google/cloud/bigtable/read_modify_write_rule.rb +129 -0
  59. data/lib/google/cloud/bigtable/read_operations.rb +345 -0
  60. data/lib/google/cloud/bigtable/row.rb +125 -0
  61. data/lib/google/cloud/bigtable/row_filter/chain_filter.rb +539 -0
  62. data/lib/google/cloud/bigtable/row_filter/condition_filter.rb +108 -0
  63. data/lib/google/cloud/bigtable/row_filter/interleave_filter.rb +570 -0
  64. data/lib/google/cloud/bigtable/row_filter/simple_filter.rb +273 -0
  65. data/lib/google/cloud/bigtable/row_filter.rb +593 -0
  66. data/lib/google/cloud/bigtable/row_range.rb +174 -0
  67. data/lib/google/cloud/bigtable/rows_mutator.rb +120 -0
  68. data/lib/google/cloud/bigtable/rows_reader.rb +196 -0
  69. data/lib/google/cloud/bigtable/sample_row_key.rb +82 -0
  70. data/lib/google/cloud/bigtable/service.rb +817 -0
  71. data/lib/google/cloud/bigtable/table/cluster_state.rb +93 -0
  72. data/lib/google/cloud/bigtable/table/column_family_map.rb +68 -0
  73. data/lib/google/cloud/bigtable/table/list.rb +147 -0
  74. data/lib/google/cloud/bigtable/table.rb +676 -0
  75. data/lib/google/cloud/bigtable/v2/bigtable_client.rb +579 -0
  76. data/lib/google/cloud/bigtable/v2/bigtable_client_config.json +65 -0
  77. data/lib/google/cloud/bigtable/v2/credentials.rb +45 -0
  78. data/lib/google/cloud/bigtable/v2/doc/google/bigtable/v2/bigtable.rb +286 -0
  79. data/lib/google/cloud/bigtable/v2/doc/google/bigtable/v2/data.rb +492 -0
  80. data/lib/google/cloud/bigtable/v2/doc/google/protobuf/any.rb +124 -0
  81. data/lib/google/cloud/bigtable/v2/doc/google/protobuf/wrappers.rb +89 -0
  82. data/lib/google/cloud/bigtable/v2/doc/google/rpc/status.rb +83 -0
  83. data/lib/google/cloud/bigtable/v2.rb +132 -0
  84. data/lib/google/cloud/bigtable/value_range.rb +175 -0
  85. data/lib/google/cloud/bigtable/version.rb +22 -0
  86. data/lib/google/cloud/bigtable.rb +223 -0
  87. data/lib/google-cloud-bigtable.rb +167 -0
  88. metadata +283 -0
@@ -0,0 +1,579 @@
1
+ # Copyright 2018 Google LLC
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # https://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+ #
15
+ # EDITING INSTRUCTIONS
16
+ # This file was generated from the file
17
+ # https://github.com/googleapis/googleapis/blob/master/google/bigtable/v2/bigtable.proto,
18
+ # and updates to that file get reflected here through a refresh process.
19
+ # For the short term, the refresh process will only be runnable by Google
20
+ # engineers.
21
+
22
+ require "json"
23
+ require "pathname"
24
+
25
+ require "google/gax"
26
+
27
+ require "google/bigtable/v2/bigtable_pb"
28
+ require "google/cloud/bigtable/v2/credentials"
29
+
30
+ module Google
31
+ module Cloud
32
+ module Bigtable
33
+ module V2
34
+ # Service for reading from and writing to existing Bigtable tables.
35
+ #
36
+ # @!attribute [r] bigtable_stub
37
+ # @return [Google::Bigtable::V2::Bigtable::Stub]
38
+ class BigtableClient
39
+ attr_reader :bigtable_stub
40
+
41
+ # The default address of the service.
42
+ SERVICE_ADDRESS = "bigtable.googleapis.com".freeze
43
+
44
+ # The default port of the service.
45
+ DEFAULT_SERVICE_PORT = 443
46
+
47
+ # The default set of gRPC interceptors.
48
+ GRPC_INTERCEPTORS = []
49
+
50
+ DEFAULT_TIMEOUT = 30
51
+
52
+ # The scopes needed to make gRPC calls to all of the methods defined in
53
+ # this service.
54
+ ALL_SCOPES = [
55
+ "https://www.googleapis.com/auth/bigtable.data",
56
+ "https://www.googleapis.com/auth/bigtable.data.readonly",
57
+ "https://www.googleapis.com/auth/cloud-bigtable.data",
58
+ "https://www.googleapis.com/auth/cloud-bigtable.data.readonly",
59
+ "https://www.googleapis.com/auth/cloud-platform",
60
+ "https://www.googleapis.com/auth/cloud-platform.read-only"
61
+ ].freeze
62
+
63
+
64
+ TABLE_PATH_TEMPLATE = Google::Gax::PathTemplate.new(
65
+ "projects/{project}/instances/{instance}/tables/{table}"
66
+ )
67
+
68
+ private_constant :TABLE_PATH_TEMPLATE
69
+
70
+ # Returns a fully-qualified table resource name string.
71
+ # @param project [String]
72
+ # @param instance [String]
73
+ # @param table [String]
74
+ # @return [String]
75
+ def self.table_path project, instance, table
76
+ TABLE_PATH_TEMPLATE.render(
77
+ :"project" => project,
78
+ :"instance" => instance,
79
+ :"table" => table
80
+ )
81
+ end
82
+
83
+ # @param credentials [Google::Auth::Credentials, String, Hash, GRPC::Core::Channel, GRPC::Core::ChannelCredentials, Proc]
84
+ # Provides the means for authenticating requests made by the client. This parameter can
85
+ # be many types.
86
+ # A `Google::Auth::Credentials` uses a the properties of its represented keyfile for
87
+ # authenticating requests made by this client.
88
+ # A `String` will be treated as the path to the keyfile to be used for the construction of
89
+ # credentials for this client.
90
+ # A `Hash` will be treated as the contents of a keyfile to be used for the construction of
91
+ # credentials for this client.
92
+ # A `GRPC::Core::Channel` will be used to make calls through.
93
+ # A `GRPC::Core::ChannelCredentials` for the setting up the RPC client. The channel credentials
94
+ # should already be composed with a `GRPC::Core::CallCredentials` object.
95
+ # A `Proc` will be used as an updater_proc for the Grpc channel. The proc transforms the
96
+ # metadata for requests, generally, to give OAuth credentials.
97
+ # @param scopes [Array<String>]
98
+ # The OAuth scopes for this service. This parameter is ignored if
99
+ # an updater_proc is supplied.
100
+ # @param client_config [Hash]
101
+ # A Hash for call options for each method. See
102
+ # Google::Gax#construct_settings for the structure of
103
+ # this data. Falls back to the default config if not specified
104
+ # or the specified config is missing data points.
105
+ # @param timeout [Numeric]
106
+ # The default timeout, in seconds, for calls made through this client.
107
+ # @param metadata [Hash]
108
+ # Default metadata to be sent with each request. This can be overridden on a per call basis.
109
+ # @param exception_transformer [Proc]
110
+ # An optional proc that intercepts any exceptions raised during an API call to inject
111
+ # custom error handling.
112
+ def initialize \
113
+ credentials: nil,
114
+ scopes: ALL_SCOPES,
115
+ client_config: {},
116
+ timeout: DEFAULT_TIMEOUT,
117
+ metadata: nil,
118
+ exception_transformer: nil,
119
+ lib_name: nil,
120
+ lib_version: ""
121
+ # These require statements are intentionally placed here to initialize
122
+ # the gRPC module only when it's required.
123
+ # See https://github.com/googleapis/toolkit/issues/446
124
+ require "google/gax/grpc"
125
+ require "google/bigtable/v2/bigtable_services_pb"
126
+
127
+ credentials ||= Google::Cloud::Bigtable::V2::Credentials.default
128
+
129
+ if credentials.is_a?(String) || credentials.is_a?(Hash)
130
+ updater_proc = Google::Cloud::Bigtable::V2::Credentials.new(credentials).updater_proc
131
+ end
132
+ if credentials.is_a?(GRPC::Core::Channel)
133
+ channel = credentials
134
+ end
135
+ if credentials.is_a?(GRPC::Core::ChannelCredentials)
136
+ chan_creds = credentials
137
+ end
138
+ if credentials.is_a?(Proc)
139
+ updater_proc = credentials
140
+ end
141
+ if credentials.is_a?(Google::Auth::Credentials)
142
+ updater_proc = credentials.updater_proc
143
+ end
144
+
145
+ package_version = Gem.loaded_specs['google-cloud-bigtable'].version.version
146
+
147
+ google_api_client = "gl-ruby/#{RUBY_VERSION}"
148
+ google_api_client << " #{lib_name}/#{lib_version}" if lib_name
149
+ google_api_client << " gapic/#{package_version} gax/#{Google::Gax::VERSION}"
150
+ google_api_client << " grpc/#{GRPC::VERSION}"
151
+ google_api_client.freeze
152
+
153
+ headers = { :"x-goog-api-client" => google_api_client }
154
+ headers.merge!(metadata) unless metadata.nil?
155
+ client_config_file = Pathname.new(__dir__).join(
156
+ "bigtable_client_config.json"
157
+ )
158
+ defaults = client_config_file.open do |f|
159
+ Google::Gax.construct_settings(
160
+ "google.bigtable.v2.Bigtable",
161
+ JSON.parse(f.read),
162
+ client_config,
163
+ Google::Gax::Grpc::STATUS_CODE_NAMES,
164
+ timeout,
165
+ errors: Google::Gax::Grpc::API_ERRORS,
166
+ metadata: headers
167
+ )
168
+ end
169
+
170
+ # Allow overriding the service path/port in subclasses.
171
+ service_path = self.class::SERVICE_ADDRESS
172
+ port = self.class::DEFAULT_SERVICE_PORT
173
+ interceptors = self.class::GRPC_INTERCEPTORS
174
+ @bigtable_stub = Google::Gax::Grpc.create_stub(
175
+ service_path,
176
+ port,
177
+ chan_creds: chan_creds,
178
+ channel: channel,
179
+ updater_proc: updater_proc,
180
+ scopes: scopes,
181
+ interceptors: interceptors,
182
+ &Google::Bigtable::V2::Bigtable::Stub.method(:new)
183
+ )
184
+
185
+ @read_rows = Google::Gax.create_api_call(
186
+ @bigtable_stub.method(:read_rows),
187
+ defaults["read_rows"],
188
+ exception_transformer: exception_transformer,
189
+ params_extractor: proc do |request|
190
+ {'table_name' => request.table_name}
191
+ end
192
+ )
193
+ @sample_row_keys = Google::Gax.create_api_call(
194
+ @bigtable_stub.method(:sample_row_keys),
195
+ defaults["sample_row_keys"],
196
+ exception_transformer: exception_transformer,
197
+ params_extractor: proc do |request|
198
+ {'table_name' => request.table_name}
199
+ end
200
+ )
201
+ @mutate_row = Google::Gax.create_api_call(
202
+ @bigtable_stub.method(:mutate_row),
203
+ defaults["mutate_row"],
204
+ exception_transformer: exception_transformer,
205
+ params_extractor: proc do |request|
206
+ {'table_name' => request.table_name}
207
+ end
208
+ )
209
+ @mutate_rows = Google::Gax.create_api_call(
210
+ @bigtable_stub.method(:mutate_rows),
211
+ defaults["mutate_rows"],
212
+ exception_transformer: exception_transformer,
213
+ params_extractor: proc do |request|
214
+ {'table_name' => request.table_name}
215
+ end
216
+ )
217
+ @check_and_mutate_row = Google::Gax.create_api_call(
218
+ @bigtable_stub.method(:check_and_mutate_row),
219
+ defaults["check_and_mutate_row"],
220
+ exception_transformer: exception_transformer,
221
+ params_extractor: proc do |request|
222
+ {'table_name' => request.table_name}
223
+ end
224
+ )
225
+ @read_modify_write_row = Google::Gax.create_api_call(
226
+ @bigtable_stub.method(:read_modify_write_row),
227
+ defaults["read_modify_write_row"],
228
+ exception_transformer: exception_transformer,
229
+ params_extractor: proc do |request|
230
+ {'table_name' => request.table_name}
231
+ end
232
+ )
233
+ end
234
+
235
+ # Service calls
236
+
237
+ # Streams back the contents of all requested rows in key order, optionally
238
+ # applying the same Reader filter to each. Depending on their size,
239
+ # rows and cells may be broken up across multiple responses, but
240
+ # atomicity of each row will still be preserved. See the
241
+ # ReadRowsResponse documentation for details.
242
+ #
243
+ # @param table_name [String]
244
+ # The unique name of the table from which to read.
245
+ # Values are of the form
246
+ # +projects/<project>/instances/<instance>/tables/<table>+.
247
+ # @param app_profile_id [String]
248
+ # This value specifies routing for replication. If not specified, the
249
+ # "default" application profile will be used.
250
+ # @param rows [Google::Bigtable::V2::RowSet | Hash]
251
+ # The row keys and/or ranges to read. If not specified, reads from all rows.
252
+ # A hash of the same form as `Google::Bigtable::V2::RowSet`
253
+ # can also be provided.
254
+ # @param filter [Google::Bigtable::V2::RowFilter | Hash]
255
+ # The filter to apply to the contents of the specified row(s). If unset,
256
+ # reads the entirety of each row.
257
+ # A hash of the same form as `Google::Bigtable::V2::RowFilter`
258
+ # can also be provided.
259
+ # @param rows_limit [Integer]
260
+ # The read will terminate after committing to N rows' worth of results. The
261
+ # default (zero) is to return all results.
262
+ # @param options [Google::Gax::CallOptions]
263
+ # Overrides the default settings for this call, e.g, timeout,
264
+ # retries, etc.
265
+ # @return [Enumerable<Google::Bigtable::V2::ReadRowsResponse>]
266
+ # An enumerable of Google::Bigtable::V2::ReadRowsResponse instances.
267
+ #
268
+ # @raise [Google::Gax::GaxError] if the RPC is aborted.
269
+ # @example
270
+ # require "google/cloud/bigtable/v2"
271
+ #
272
+ # bigtable_client = Google::Cloud::Bigtable::V2.new
273
+ # formatted_table_name = Google::Cloud::Bigtable::V2::BigtableClient.table_path("[PROJECT]", "[INSTANCE]", "[TABLE]")
274
+ # bigtable_client.read_rows(formatted_table_name).each do |element|
275
+ # # Process element.
276
+ # end
277
+
278
+ def read_rows \
279
+ table_name,
280
+ app_profile_id: nil,
281
+ rows: nil,
282
+ filter: nil,
283
+ rows_limit: nil,
284
+ options: nil
285
+ req = {
286
+ table_name: table_name,
287
+ app_profile_id: app_profile_id,
288
+ rows: rows,
289
+ filter: filter,
290
+ rows_limit: rows_limit
291
+ }.delete_if { |_, v| v.nil? }
292
+ req = Google::Gax::to_proto(req, Google::Bigtable::V2::ReadRowsRequest)
293
+ @read_rows.call(req, options)
294
+ end
295
+
296
+ # Returns a sample of row keys in the table. The returned row keys will
297
+ # delimit contiguous sections of the table of approximately equal size,
298
+ # which can be used to break up the data for distributed tasks like
299
+ # mapreduces.
300
+ #
301
+ # @param table_name [String]
302
+ # The unique name of the table from which to sample row keys.
303
+ # Values are of the form
304
+ # +projects/<project>/instances/<instance>/tables/<table>+.
305
+ # @param app_profile_id [String]
306
+ # This value specifies routing for replication. If not specified, the
307
+ # "default" application profile will be used.
308
+ # @param options [Google::Gax::CallOptions]
309
+ # Overrides the default settings for this call, e.g, timeout,
310
+ # retries, etc.
311
+ # @return [Enumerable<Google::Bigtable::V2::SampleRowKeysResponse>]
312
+ # An enumerable of Google::Bigtable::V2::SampleRowKeysResponse instances.
313
+ #
314
+ # @raise [Google::Gax::GaxError] if the RPC is aborted.
315
+ # @example
316
+ # require "google/cloud/bigtable/v2"
317
+ #
318
+ # bigtable_client = Google::Cloud::Bigtable::V2.new
319
+ # formatted_table_name = Google::Cloud::Bigtable::V2::BigtableClient.table_path("[PROJECT]", "[INSTANCE]", "[TABLE]")
320
+ # bigtable_client.sample_row_keys(formatted_table_name).each do |element|
321
+ # # Process element.
322
+ # end
323
+
324
+ def sample_row_keys \
325
+ table_name,
326
+ app_profile_id: nil,
327
+ options: nil
328
+ req = {
329
+ table_name: table_name,
330
+ app_profile_id: app_profile_id
331
+ }.delete_if { |_, v| v.nil? }
332
+ req = Google::Gax::to_proto(req, Google::Bigtable::V2::SampleRowKeysRequest)
333
+ @sample_row_keys.call(req, options)
334
+ end
335
+
336
+ # Mutates a row atomically. Cells already present in the row are left
337
+ # unchanged unless explicitly changed by +mutation+.
338
+ #
339
+ # @param table_name [String]
340
+ # The unique name of the table to which the mutation should be applied.
341
+ # Values are of the form
342
+ # +projects/<project>/instances/<instance>/tables/<table>+.
343
+ # @param row_key [String]
344
+ # The key of the row to which the mutation should be applied.
345
+ # @param mutations [Array<Google::Bigtable::V2::Mutation | Hash>]
346
+ # Changes to be atomically applied to the specified row. Entries are applied
347
+ # in order, meaning that earlier mutations can be masked by later ones.
348
+ # Must contain at least one entry and at most 100000.
349
+ # A hash of the same form as `Google::Bigtable::V2::Mutation`
350
+ # can also be provided.
351
+ # @param app_profile_id [String]
352
+ # This value specifies routing for replication. If not specified, the
353
+ # "default" application profile will be used.
354
+ # @param options [Google::Gax::CallOptions]
355
+ # Overrides the default settings for this call, e.g, timeout,
356
+ # retries, etc.
357
+ # @yield [result, operation] Access the result along with the RPC operation
358
+ # @yieldparam result [Google::Bigtable::V2::MutateRowResponse]
359
+ # @yieldparam operation [GRPC::ActiveCall::Operation]
360
+ # @return [Google::Bigtable::V2::MutateRowResponse]
361
+ # @raise [Google::Gax::GaxError] if the RPC is aborted.
362
+ # @example
363
+ # require "google/cloud/bigtable/v2"
364
+ #
365
+ # bigtable_client = Google::Cloud::Bigtable::V2.new
366
+ # formatted_table_name = Google::Cloud::Bigtable::V2::BigtableClient.table_path("[PROJECT]", "[INSTANCE]", "[TABLE]")
367
+ #
368
+ # # TODO: Initialize +row_key+:
369
+ # row_key = ''
370
+ #
371
+ # # TODO: Initialize +mutations+:
372
+ # mutations = []
373
+ # response = bigtable_client.mutate_row(formatted_table_name, row_key, mutations)
374
+
375
+ def mutate_row \
376
+ table_name,
377
+ row_key,
378
+ mutations,
379
+ app_profile_id: nil,
380
+ options: nil,
381
+ &block
382
+ req = {
383
+ table_name: table_name,
384
+ row_key: row_key,
385
+ mutations: mutations,
386
+ app_profile_id: app_profile_id
387
+ }.delete_if { |_, v| v.nil? }
388
+ req = Google::Gax::to_proto(req, Google::Bigtable::V2::MutateRowRequest)
389
+ @mutate_row.call(req, options, &block)
390
+ end
391
+
392
+ # Mutates multiple rows in a batch. Each individual row is mutated
393
+ # atomically as in MutateRow, but the entire batch is not executed
394
+ # atomically.
395
+ #
396
+ # @param table_name [String]
397
+ # The unique name of the table to which the mutations should be applied.
398
+ # @param entries [Array<Google::Bigtable::V2::MutateRowsRequest::Entry | Hash>]
399
+ # The row keys and corresponding mutations to be applied in bulk.
400
+ # Each entry is applied as an atomic mutation, but the entries may be
401
+ # applied in arbitrary order (even between entries for the same row).
402
+ # At least one entry must be specified, and in total the entries can
403
+ # contain at most 100000 mutations.
404
+ # A hash of the same form as `Google::Bigtable::V2::MutateRowsRequest::Entry`
405
+ # can also be provided.
406
+ # @param app_profile_id [String]
407
+ # This value specifies routing for replication. If not specified, the
408
+ # "default" application profile will be used.
409
+ # @param options [Google::Gax::CallOptions]
410
+ # Overrides the default settings for this call, e.g, timeout,
411
+ # retries, etc.
412
+ # @return [Enumerable<Google::Bigtable::V2::MutateRowsResponse>]
413
+ # An enumerable of Google::Bigtable::V2::MutateRowsResponse instances.
414
+ #
415
+ # @raise [Google::Gax::GaxError] if the RPC is aborted.
416
+ # @example
417
+ # require "google/cloud/bigtable/v2"
418
+ #
419
+ # bigtable_client = Google::Cloud::Bigtable::V2.new
420
+ # formatted_table_name = Google::Cloud::Bigtable::V2::BigtableClient.table_path("[PROJECT]", "[INSTANCE]", "[TABLE]")
421
+ #
422
+ # # TODO: Initialize +entries+:
423
+ # entries = []
424
+ # bigtable_client.mutate_rows(formatted_table_name, entries).each do |element|
425
+ # # Process element.
426
+ # end
427
+
428
+ def mutate_rows \
429
+ table_name,
430
+ entries,
431
+ app_profile_id: nil,
432
+ options: nil
433
+ req = {
434
+ table_name: table_name,
435
+ entries: entries,
436
+ app_profile_id: app_profile_id
437
+ }.delete_if { |_, v| v.nil? }
438
+ req = Google::Gax::to_proto(req, Google::Bigtable::V2::MutateRowsRequest)
439
+ @mutate_rows.call(req, options)
440
+ end
441
+
442
+ # Mutates a row atomically based on the output of a predicate Reader filter.
443
+ #
444
+ # @param table_name [String]
445
+ # The unique name of the table to which the conditional mutation should be
446
+ # applied.
447
+ # Values are of the form
448
+ # +projects/<project>/instances/<instance>/tables/<table>+.
449
+ # @param row_key [String]
450
+ # The key of the row to which the conditional mutation should be applied.
451
+ # @param app_profile_id [String]
452
+ # This value specifies routing for replication. If not specified, the
453
+ # "default" application profile will be used.
454
+ # @param predicate_filter [Google::Bigtable::V2::RowFilter | Hash]
455
+ # The filter to be applied to the contents of the specified row. Depending
456
+ # on whether or not any results are yielded, either +true_mutations+ or
457
+ # +false_mutations+ will be executed. If unset, checks that the row contains
458
+ # any values at all.
459
+ # A hash of the same form as `Google::Bigtable::V2::RowFilter`
460
+ # can also be provided.
461
+ # @param true_mutations [Array<Google::Bigtable::V2::Mutation | Hash>]
462
+ # Changes to be atomically applied to the specified row if +predicate_filter+
463
+ # yields at least one cell when applied to +row_key+. Entries are applied in
464
+ # order, meaning that earlier mutations can be masked by later ones.
465
+ # Must contain at least one entry if +false_mutations+ is empty, and at most
466
+ # 100000.
467
+ # A hash of the same form as `Google::Bigtable::V2::Mutation`
468
+ # can also be provided.
469
+ # @param false_mutations [Array<Google::Bigtable::V2::Mutation | Hash>]
470
+ # Changes to be atomically applied to the specified row if +predicate_filter+
471
+ # does not yield any cells when applied to +row_key+. Entries are applied in
472
+ # order, meaning that earlier mutations can be masked by later ones.
473
+ # Must contain at least one entry if +true_mutations+ is empty, and at most
474
+ # 100000.
475
+ # A hash of the same form as `Google::Bigtable::V2::Mutation`
476
+ # can also be provided.
477
+ # @param options [Google::Gax::CallOptions]
478
+ # Overrides the default settings for this call, e.g, timeout,
479
+ # retries, etc.
480
+ # @yield [result, operation] Access the result along with the RPC operation
481
+ # @yieldparam result [Google::Bigtable::V2::CheckAndMutateRowResponse]
482
+ # @yieldparam operation [GRPC::ActiveCall::Operation]
483
+ # @return [Google::Bigtable::V2::CheckAndMutateRowResponse]
484
+ # @raise [Google::Gax::GaxError] if the RPC is aborted.
485
+ # @example
486
+ # require "google/cloud/bigtable/v2"
487
+ #
488
+ # bigtable_client = Google::Cloud::Bigtable::V2.new
489
+ # formatted_table_name = Google::Cloud::Bigtable::V2::BigtableClient.table_path("[PROJECT]", "[INSTANCE]", "[TABLE]")
490
+ #
491
+ # # TODO: Initialize +row_key+:
492
+ # row_key = ''
493
+ # response = bigtable_client.check_and_mutate_row(formatted_table_name, row_key)
494
+
495
+ def check_and_mutate_row \
496
+ table_name,
497
+ row_key,
498
+ app_profile_id: nil,
499
+ predicate_filter: nil,
500
+ true_mutations: nil,
501
+ false_mutations: nil,
502
+ options: nil,
503
+ &block
504
+ req = {
505
+ table_name: table_name,
506
+ row_key: row_key,
507
+ app_profile_id: app_profile_id,
508
+ predicate_filter: predicate_filter,
509
+ true_mutations: true_mutations,
510
+ false_mutations: false_mutations
511
+ }.delete_if { |_, v| v.nil? }
512
+ req = Google::Gax::to_proto(req, Google::Bigtable::V2::CheckAndMutateRowRequest)
513
+ @check_and_mutate_row.call(req, options, &block)
514
+ end
515
+
516
+ # Modifies a row atomically on the server. The method reads the latest
517
+ # existing timestamp and value from the specified columns and writes a new
518
+ # entry based on pre-defined read/modify/write rules. The new value for the
519
+ # timestamp is the greater of the existing timestamp or the current server
520
+ # time. The method returns the new contents of all modified cells.
521
+ #
522
+ # @param table_name [String]
523
+ # The unique name of the table to which the read/modify/write rules should be
524
+ # applied.
525
+ # Values are of the form
526
+ # +projects/<project>/instances/<instance>/tables/<table>+.
527
+ # @param row_key [String]
528
+ # The key of the row to which the read/modify/write rules should be applied.
529
+ # @param rules [Array<Google::Bigtable::V2::ReadModifyWriteRule | Hash>]
530
+ # Rules specifying how the specified row's contents are to be transformed
531
+ # into writes. Entries are applied in order, meaning that earlier rules will
532
+ # affect the results of later ones.
533
+ # A hash of the same form as `Google::Bigtable::V2::ReadModifyWriteRule`
534
+ # can also be provided.
535
+ # @param app_profile_id [String]
536
+ # This value specifies routing for replication. If not specified, the
537
+ # "default" application profile will be used.
538
+ # @param options [Google::Gax::CallOptions]
539
+ # Overrides the default settings for this call, e.g, timeout,
540
+ # retries, etc.
541
+ # @yield [result, operation] Access the result along with the RPC operation
542
+ # @yieldparam result [Google::Bigtable::V2::ReadModifyWriteRowResponse]
543
+ # @yieldparam operation [GRPC::ActiveCall::Operation]
544
+ # @return [Google::Bigtable::V2::ReadModifyWriteRowResponse]
545
+ # @raise [Google::Gax::GaxError] if the RPC is aborted.
546
+ # @example
547
+ # require "google/cloud/bigtable/v2"
548
+ #
549
+ # bigtable_client = Google::Cloud::Bigtable::V2.new
550
+ # formatted_table_name = Google::Cloud::Bigtable::V2::BigtableClient.table_path("[PROJECT]", "[INSTANCE]", "[TABLE]")
551
+ #
552
+ # # TODO: Initialize +row_key+:
553
+ # row_key = ''
554
+ #
555
+ # # TODO: Initialize +rules+:
556
+ # rules = []
557
+ # response = bigtable_client.read_modify_write_row(formatted_table_name, row_key, rules)
558
+
559
+ def read_modify_write_row \
560
+ table_name,
561
+ row_key,
562
+ rules,
563
+ app_profile_id: nil,
564
+ options: nil,
565
+ &block
566
+ req = {
567
+ table_name: table_name,
568
+ row_key: row_key,
569
+ rules: rules,
570
+ app_profile_id: app_profile_id
571
+ }.delete_if { |_, v| v.nil? }
572
+ req = Google::Gax::to_proto(req, Google::Bigtable::V2::ReadModifyWriteRowRequest)
573
+ @read_modify_write_row.call(req, options, &block)
574
+ end
575
+ end
576
+ end
577
+ end
578
+ end
579
+ end