google-cloud-bigtable 1.3.0

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