google-cloud-bigtable-v2 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,841 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright 2020 Google LLC
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # https://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+
17
+ # Auto-generated by gapic-generator-ruby. DO NOT EDIT!
18
+
19
+ require "google/cloud/errors"
20
+ require "google/bigtable/v2/bigtable_pb"
21
+
22
+ module Google
23
+ module Cloud
24
+ module Bigtable
25
+ module V2
26
+ module Bigtable
27
+ ##
28
+ # Client for the Bigtable service.
29
+ #
30
+ # Service for reading from and writing to existing Bigtable tables.
31
+ #
32
+ class Client
33
+ include Paths
34
+
35
+ # @private
36
+ attr_reader :bigtable_stub
37
+
38
+ ##
39
+ # Configure the Bigtable Client class.
40
+ #
41
+ # See {::Google::Cloud::Bigtable::V2::Bigtable::Client::Configuration}
42
+ # for a description of the configuration fields.
43
+ #
44
+ # ## Example
45
+ #
46
+ # To modify the configuration for all Bigtable clients:
47
+ #
48
+ # ::Google::Cloud::Bigtable::V2::Bigtable::Client.configure do |config|
49
+ # config.timeout = 10.0
50
+ # end
51
+ #
52
+ # @yield [config] Configure the Client client.
53
+ # @yieldparam config [Client::Configuration]
54
+ #
55
+ # @return [Client::Configuration]
56
+ #
57
+ def self.configure
58
+ @configure ||= begin
59
+ namespace = ["Google", "Cloud", "Bigtable", "V2"]
60
+ parent_config = while namespace.any?
61
+ parent_name = namespace.join "::"
62
+ parent_const = const_get parent_name
63
+ break parent_const.configure if parent_const&.respond_to? :configure
64
+ namespace.pop
65
+ end
66
+ default_config = Client::Configuration.new parent_config
67
+
68
+ default_config.rpcs.read_rows.timeout = 43_200.0
69
+
70
+ default_config.rpcs.sample_row_keys.timeout = 60.0
71
+
72
+ default_config.rpcs.mutate_row.timeout = 60.0
73
+ default_config.rpcs.mutate_row.retry_policy = {
74
+ initial_delay: 0.01,
75
+ max_delay: 60.0,
76
+ multiplier: 2,
77
+ retry_codes: ["UNAVAILABLE", "DEADLINE_EXCEEDED"]
78
+ }
79
+
80
+ default_config.rpcs.mutate_rows.timeout = 600.0
81
+
82
+ default_config.rpcs.check_and_mutate_row.timeout = 20.0
83
+
84
+ default_config.rpcs.read_modify_write_row.timeout = 20.0
85
+
86
+ default_config
87
+ end
88
+ yield @configure if block_given?
89
+ @configure
90
+ end
91
+
92
+ ##
93
+ # Configure the Bigtable Client instance.
94
+ #
95
+ # The configuration is set to the derived mode, meaning that values can be changed,
96
+ # but structural changes (adding new fields, etc.) are not allowed. Structural changes
97
+ # should be made on {Client.configure}.
98
+ #
99
+ # See {::Google::Cloud::Bigtable::V2::Bigtable::Client::Configuration}
100
+ # for a description of the configuration fields.
101
+ #
102
+ # @yield [config] Configure the Client client.
103
+ # @yieldparam config [Client::Configuration]
104
+ #
105
+ # @return [Client::Configuration]
106
+ #
107
+ def configure
108
+ yield @config if block_given?
109
+ @config
110
+ end
111
+
112
+ ##
113
+ # Create a new Bigtable client object.
114
+ #
115
+ # ## Examples
116
+ #
117
+ # To create a new Bigtable client with the default
118
+ # configuration:
119
+ #
120
+ # client = ::Google::Cloud::Bigtable::V2::Bigtable::Client.new
121
+ #
122
+ # To create a new Bigtable client with a custom
123
+ # configuration:
124
+ #
125
+ # client = ::Google::Cloud::Bigtable::V2::Bigtable::Client.new do |config|
126
+ # config.timeout = 10.0
127
+ # end
128
+ #
129
+ # @yield [config] Configure the Bigtable client.
130
+ # @yieldparam config [Client::Configuration]
131
+ #
132
+ def initialize
133
+ # These require statements are intentionally placed here to initialize
134
+ # the gRPC module only when it's required.
135
+ # See https://github.com/googleapis/toolkit/issues/446
136
+ require "gapic/grpc"
137
+ require "google/bigtable/v2/bigtable_services_pb"
138
+
139
+ # Create the configuration object
140
+ @config = Configuration.new Client.configure
141
+
142
+ # Yield the configuration if needed
143
+ yield @config if block_given?
144
+
145
+ # Create credentials
146
+ credentials = @config.credentials
147
+ credentials ||= Credentials.default scope: @config.scope
148
+ if credentials.is_a?(String) || credentials.is_a?(Hash)
149
+ credentials = Credentials.new credentials, scope: @config.scope
150
+ end
151
+ @quota_project_id = @config.quota_project
152
+ @quota_project_id ||= credentials.quota_project_id if credentials.respond_to? :quota_project_id
153
+
154
+ @bigtable_stub = ::Gapic::ServiceStub.new(
155
+ ::Google::Cloud::Bigtable::V2::Bigtable::Stub,
156
+ credentials: credentials,
157
+ endpoint: @config.endpoint,
158
+ channel_args: @config.channel_args,
159
+ interceptors: @config.interceptors
160
+ )
161
+ end
162
+
163
+ # Service calls
164
+
165
+ ##
166
+ # Streams back the contents of all requested rows in key order, optionally
167
+ # applying the same Reader filter to each. Depending on their size,
168
+ # rows and cells may be broken up across multiple responses, but
169
+ # atomicity of each row will still be preserved. See the
170
+ # ReadRowsResponse documentation for details.
171
+ #
172
+ # @overload read_rows(request, options = nil)
173
+ # Pass arguments to `read_rows` via a request object, either of type
174
+ # {::Google::Cloud::Bigtable::V2::ReadRowsRequest} or an equivalent Hash.
175
+ #
176
+ # @param request [::Google::Cloud::Bigtable::V2::ReadRowsRequest, ::Hash]
177
+ # A request object representing the call parameters. Required. To specify no
178
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
179
+ # @param options [::Gapic::CallOptions, ::Hash]
180
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
181
+ #
182
+ # @overload read_rows(table_name: nil, app_profile_id: nil, rows: nil, filter: nil, rows_limit: nil)
183
+ # Pass arguments to `read_rows` via keyword arguments. Note that at
184
+ # least one keyword argument is required. To specify no parameters, or to keep all
185
+ # the default parameter values, pass an empty Hash as a request object (see above).
186
+ #
187
+ # @param table_name [::String]
188
+ # Required. The unique name of the table from which to read.
189
+ # Values are of the form
190
+ # `projects/<project>/instances/<instance>/tables/<table>`.
191
+ # @param app_profile_id [::String]
192
+ # This value specifies routing for replication. If not specified, the
193
+ # "default" application profile will be used.
194
+ # @param rows [::Google::Cloud::Bigtable::V2::RowSet, ::Hash]
195
+ # The row keys and/or ranges to read. If not specified, reads from all rows.
196
+ # @param filter [::Google::Cloud::Bigtable::V2::RowFilter, ::Hash]
197
+ # The filter to apply to the contents of the specified row(s). If unset,
198
+ # reads the entirety of each row.
199
+ # @param rows_limit [::Integer]
200
+ # The read will terminate after committing to N rows' worth of results. The
201
+ # default (zero) is to return all results.
202
+ #
203
+ # @yield [response, operation] Access the result along with the RPC operation
204
+ # @yieldparam response [::Enumerable<::Google::Cloud::Bigtable::V2::ReadRowsResponse>]
205
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
206
+ #
207
+ # @return [::Enumerable<::Google::Cloud::Bigtable::V2::ReadRowsResponse>]
208
+ #
209
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
210
+ #
211
+ def read_rows request, options = nil
212
+ raise ::ArgumentError, "request must be provided" if request.nil?
213
+
214
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Bigtable::V2::ReadRowsRequest
215
+
216
+ # Converts hash and nil to an options object
217
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
218
+
219
+ # Customize the options with defaults
220
+ metadata = @config.rpcs.read_rows.metadata.to_h
221
+
222
+ # Set x-goog-api-client and x-goog-user-project headers
223
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
224
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
225
+ gapic_version: ::Google::Cloud::Bigtable::V2::VERSION
226
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
227
+
228
+ header_params = {
229
+ "table_name" => request.table_name
230
+ }
231
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
232
+ metadata[:"x-goog-request-params"] ||= request_params_header
233
+
234
+ options.apply_defaults timeout: @config.rpcs.read_rows.timeout,
235
+ metadata: metadata,
236
+ retry_policy: @config.rpcs.read_rows.retry_policy
237
+ options.apply_defaults metadata: @config.metadata,
238
+ retry_policy: @config.retry_policy
239
+
240
+ @bigtable_stub.call_rpc :read_rows, request, options: options do |response, operation|
241
+ yield response, operation if block_given?
242
+ return response
243
+ end
244
+ rescue ::GRPC::BadStatus => e
245
+ raise ::Google::Cloud::Error.from_error(e)
246
+ end
247
+
248
+ ##
249
+ # Returns a sample of row keys in the table. The returned row keys will
250
+ # delimit contiguous sections of the table of approximately equal size,
251
+ # which can be used to break up the data for distributed tasks like
252
+ # mapreduces.
253
+ #
254
+ # @overload sample_row_keys(request, options = nil)
255
+ # Pass arguments to `sample_row_keys` via a request object, either of type
256
+ # {::Google::Cloud::Bigtable::V2::SampleRowKeysRequest} or an equivalent Hash.
257
+ #
258
+ # @param request [::Google::Cloud::Bigtable::V2::SampleRowKeysRequest, ::Hash]
259
+ # A request object representing the call parameters. Required. To specify no
260
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
261
+ # @param options [::Gapic::CallOptions, ::Hash]
262
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
263
+ #
264
+ # @overload sample_row_keys(table_name: nil, app_profile_id: nil)
265
+ # Pass arguments to `sample_row_keys` via keyword arguments. Note that at
266
+ # least one keyword argument is required. To specify no parameters, or to keep all
267
+ # the default parameter values, pass an empty Hash as a request object (see above).
268
+ #
269
+ # @param table_name [::String]
270
+ # Required. The unique name of the table from which to sample row keys.
271
+ # Values are of the form
272
+ # `projects/<project>/instances/<instance>/tables/<table>`.
273
+ # @param app_profile_id [::String]
274
+ # This value specifies routing for replication. If not specified, the
275
+ # "default" application profile will be used.
276
+ #
277
+ # @yield [response, operation] Access the result along with the RPC operation
278
+ # @yieldparam response [::Enumerable<::Google::Cloud::Bigtable::V2::SampleRowKeysResponse>]
279
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
280
+ #
281
+ # @return [::Enumerable<::Google::Cloud::Bigtable::V2::SampleRowKeysResponse>]
282
+ #
283
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
284
+ #
285
+ def sample_row_keys request, options = nil
286
+ raise ::ArgumentError, "request must be provided" if request.nil?
287
+
288
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Bigtable::V2::SampleRowKeysRequest
289
+
290
+ # Converts hash and nil to an options object
291
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
292
+
293
+ # Customize the options with defaults
294
+ metadata = @config.rpcs.sample_row_keys.metadata.to_h
295
+
296
+ # Set x-goog-api-client and x-goog-user-project headers
297
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
298
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
299
+ gapic_version: ::Google::Cloud::Bigtable::V2::VERSION
300
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
301
+
302
+ header_params = {
303
+ "table_name" => request.table_name
304
+ }
305
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
306
+ metadata[:"x-goog-request-params"] ||= request_params_header
307
+
308
+ options.apply_defaults timeout: @config.rpcs.sample_row_keys.timeout,
309
+ metadata: metadata,
310
+ retry_policy: @config.rpcs.sample_row_keys.retry_policy
311
+ options.apply_defaults metadata: @config.metadata,
312
+ retry_policy: @config.retry_policy
313
+
314
+ @bigtable_stub.call_rpc :sample_row_keys, request, options: options do |response, operation|
315
+ yield response, operation if block_given?
316
+ return response
317
+ end
318
+ rescue ::GRPC::BadStatus => e
319
+ raise ::Google::Cloud::Error.from_error(e)
320
+ end
321
+
322
+ ##
323
+ # Mutates a row atomically. Cells already present in the row are left
324
+ # unchanged unless explicitly changed by `mutation`.
325
+ #
326
+ # @overload mutate_row(request, options = nil)
327
+ # Pass arguments to `mutate_row` via a request object, either of type
328
+ # {::Google::Cloud::Bigtable::V2::MutateRowRequest} or an equivalent Hash.
329
+ #
330
+ # @param request [::Google::Cloud::Bigtable::V2::MutateRowRequest, ::Hash]
331
+ # A request object representing the call parameters. Required. To specify no
332
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
333
+ # @param options [::Gapic::CallOptions, ::Hash]
334
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
335
+ #
336
+ # @overload mutate_row(table_name: nil, app_profile_id: nil, row_key: nil, mutations: nil)
337
+ # Pass arguments to `mutate_row` via keyword arguments. Note that at
338
+ # least one keyword argument is required. To specify no parameters, or to keep all
339
+ # the default parameter values, pass an empty Hash as a request object (see above).
340
+ #
341
+ # @param table_name [::String]
342
+ # Required. The unique name of the table to which the mutation should be applied.
343
+ # Values are of the form
344
+ # `projects/<project>/instances/<instance>/tables/<table>`.
345
+ # @param app_profile_id [::String]
346
+ # This value specifies routing for replication. If not specified, the
347
+ # "default" application profile will be used.
348
+ # @param row_key [::String]
349
+ # Required. The key of the row to which the mutation should be applied.
350
+ # @param mutations [::Array<::Google::Cloud::Bigtable::V2::Mutation, ::Hash>]
351
+ # Required. Changes to be atomically applied to the specified row. Entries are applied
352
+ # in order, meaning that earlier mutations can be masked by later ones.
353
+ # Must contain at least one entry and at most 100000.
354
+ #
355
+ # @yield [response, operation] Access the result along with the RPC operation
356
+ # @yieldparam response [::Google::Cloud::Bigtable::V2::MutateRowResponse]
357
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
358
+ #
359
+ # @return [::Google::Cloud::Bigtable::V2::MutateRowResponse]
360
+ #
361
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
362
+ #
363
+ def mutate_row request, options = nil
364
+ raise ::ArgumentError, "request must be provided" if request.nil?
365
+
366
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Bigtable::V2::MutateRowRequest
367
+
368
+ # Converts hash and nil to an options object
369
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
370
+
371
+ # Customize the options with defaults
372
+ metadata = @config.rpcs.mutate_row.metadata.to_h
373
+
374
+ # Set x-goog-api-client and x-goog-user-project headers
375
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
376
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
377
+ gapic_version: ::Google::Cloud::Bigtable::V2::VERSION
378
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
379
+
380
+ header_params = {
381
+ "table_name" => request.table_name
382
+ }
383
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
384
+ metadata[:"x-goog-request-params"] ||= request_params_header
385
+
386
+ options.apply_defaults timeout: @config.rpcs.mutate_row.timeout,
387
+ metadata: metadata,
388
+ retry_policy: @config.rpcs.mutate_row.retry_policy
389
+ options.apply_defaults metadata: @config.metadata,
390
+ retry_policy: @config.retry_policy
391
+
392
+ @bigtable_stub.call_rpc :mutate_row, request, options: options do |response, operation|
393
+ yield response, operation if block_given?
394
+ return response
395
+ end
396
+ rescue ::GRPC::BadStatus => e
397
+ raise ::Google::Cloud::Error.from_error(e)
398
+ end
399
+
400
+ ##
401
+ # Mutates multiple rows in a batch. Each individual row is mutated
402
+ # atomically as in MutateRow, but the entire batch is not executed
403
+ # atomically.
404
+ #
405
+ # @overload mutate_rows(request, options = nil)
406
+ # Pass arguments to `mutate_rows` via a request object, either of type
407
+ # {::Google::Cloud::Bigtable::V2::MutateRowsRequest} or an equivalent Hash.
408
+ #
409
+ # @param request [::Google::Cloud::Bigtable::V2::MutateRowsRequest, ::Hash]
410
+ # A request object representing the call parameters. Required. To specify no
411
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
412
+ # @param options [::Gapic::CallOptions, ::Hash]
413
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
414
+ #
415
+ # @overload mutate_rows(table_name: nil, app_profile_id: nil, entries: nil)
416
+ # Pass arguments to `mutate_rows` via keyword arguments. Note that at
417
+ # least one keyword argument is required. To specify no parameters, or to keep all
418
+ # the default parameter values, pass an empty Hash as a request object (see above).
419
+ #
420
+ # @param table_name [::String]
421
+ # Required. The unique name of the table to which the mutations should be applied.
422
+ # @param app_profile_id [::String]
423
+ # This value specifies routing for replication. If not specified, the
424
+ # "default" application profile will be used.
425
+ # @param entries [::Array<::Google::Cloud::Bigtable::V2::MutateRowsRequest::Entry, ::Hash>]
426
+ # Required. The row keys and corresponding mutations to be applied in bulk.
427
+ # Each entry is applied as an atomic mutation, but the entries may be
428
+ # applied in arbitrary order (even between entries for the same row).
429
+ # At least one entry must be specified, and in total the entries can
430
+ # contain at most 100000 mutations.
431
+ #
432
+ # @yield [response, operation] Access the result along with the RPC operation
433
+ # @yieldparam response [::Enumerable<::Google::Cloud::Bigtable::V2::MutateRowsResponse>]
434
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
435
+ #
436
+ # @return [::Enumerable<::Google::Cloud::Bigtable::V2::MutateRowsResponse>]
437
+ #
438
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
439
+ #
440
+ def mutate_rows request, options = nil
441
+ raise ::ArgumentError, "request must be provided" if request.nil?
442
+
443
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Bigtable::V2::MutateRowsRequest
444
+
445
+ # Converts hash and nil to an options object
446
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
447
+
448
+ # Customize the options with defaults
449
+ metadata = @config.rpcs.mutate_rows.metadata.to_h
450
+
451
+ # Set x-goog-api-client and x-goog-user-project headers
452
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
453
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
454
+ gapic_version: ::Google::Cloud::Bigtable::V2::VERSION
455
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
456
+
457
+ header_params = {
458
+ "table_name" => request.table_name
459
+ }
460
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
461
+ metadata[:"x-goog-request-params"] ||= request_params_header
462
+
463
+ options.apply_defaults timeout: @config.rpcs.mutate_rows.timeout,
464
+ metadata: metadata,
465
+ retry_policy: @config.rpcs.mutate_rows.retry_policy
466
+ options.apply_defaults metadata: @config.metadata,
467
+ retry_policy: @config.retry_policy
468
+
469
+ @bigtable_stub.call_rpc :mutate_rows, request, options: options do |response, operation|
470
+ yield response, operation if block_given?
471
+ return response
472
+ end
473
+ rescue ::GRPC::BadStatus => e
474
+ raise ::Google::Cloud::Error.from_error(e)
475
+ end
476
+
477
+ ##
478
+ # Mutates a row atomically based on the output of a predicate Reader filter.
479
+ #
480
+ # @overload check_and_mutate_row(request, options = nil)
481
+ # Pass arguments to `check_and_mutate_row` via a request object, either of type
482
+ # {::Google::Cloud::Bigtable::V2::CheckAndMutateRowRequest} or an equivalent Hash.
483
+ #
484
+ # @param request [::Google::Cloud::Bigtable::V2::CheckAndMutateRowRequest, ::Hash]
485
+ # A request object representing the call parameters. Required. To specify no
486
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
487
+ # @param options [::Gapic::CallOptions, ::Hash]
488
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
489
+ #
490
+ # @overload check_and_mutate_row(table_name: nil, app_profile_id: nil, row_key: nil, predicate_filter: nil, true_mutations: nil, false_mutations: nil)
491
+ # Pass arguments to `check_and_mutate_row` via keyword arguments. Note that at
492
+ # least one keyword argument is required. To specify no parameters, or to keep all
493
+ # the default parameter values, pass an empty Hash as a request object (see above).
494
+ #
495
+ # @param table_name [::String]
496
+ # Required. The unique name of the table to which the conditional mutation should be
497
+ # applied.
498
+ # Values are of the form
499
+ # `projects/<project>/instances/<instance>/tables/<table>`.
500
+ # @param app_profile_id [::String]
501
+ # This value specifies routing for replication. If not specified, the
502
+ # "default" application profile will be used.
503
+ # @param row_key [::String]
504
+ # Required. The key of the row to which the conditional mutation should be applied.
505
+ # @param predicate_filter [::Google::Cloud::Bigtable::V2::RowFilter, ::Hash]
506
+ # The filter to be applied to the contents of the specified row. Depending
507
+ # on whether or not any results are yielded, either `true_mutations` or
508
+ # `false_mutations` will be executed. If unset, checks that the row contains
509
+ # any values at all.
510
+ # @param true_mutations [::Array<::Google::Cloud::Bigtable::V2::Mutation, ::Hash>]
511
+ # Changes to be atomically applied to the specified row if `predicate_filter`
512
+ # yields at least one cell when applied to `row_key`. Entries are applied in
513
+ # order, meaning that earlier mutations can be masked by later ones.
514
+ # Must contain at least one entry if `false_mutations` is empty, and at most
515
+ # 100000.
516
+ # @param false_mutations [::Array<::Google::Cloud::Bigtable::V2::Mutation, ::Hash>]
517
+ # Changes to be atomically applied to the specified row if `predicate_filter`
518
+ # does not yield any cells when applied to `row_key`. Entries are applied in
519
+ # order, meaning that earlier mutations can be masked by later ones.
520
+ # Must contain at least one entry if `true_mutations` is empty, and at most
521
+ # 100000.
522
+ #
523
+ # @yield [response, operation] Access the result along with the RPC operation
524
+ # @yieldparam response [::Google::Cloud::Bigtable::V2::CheckAndMutateRowResponse]
525
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
526
+ #
527
+ # @return [::Google::Cloud::Bigtable::V2::CheckAndMutateRowResponse]
528
+ #
529
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
530
+ #
531
+ def check_and_mutate_row request, options = nil
532
+ raise ::ArgumentError, "request must be provided" if request.nil?
533
+
534
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Bigtable::V2::CheckAndMutateRowRequest
535
+
536
+ # Converts hash and nil to an options object
537
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
538
+
539
+ # Customize the options with defaults
540
+ metadata = @config.rpcs.check_and_mutate_row.metadata.to_h
541
+
542
+ # Set x-goog-api-client and x-goog-user-project headers
543
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
544
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
545
+ gapic_version: ::Google::Cloud::Bigtable::V2::VERSION
546
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
547
+
548
+ header_params = {
549
+ "table_name" => request.table_name
550
+ }
551
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
552
+ metadata[:"x-goog-request-params"] ||= request_params_header
553
+
554
+ options.apply_defaults timeout: @config.rpcs.check_and_mutate_row.timeout,
555
+ metadata: metadata,
556
+ retry_policy: @config.rpcs.check_and_mutate_row.retry_policy
557
+ options.apply_defaults metadata: @config.metadata,
558
+ retry_policy: @config.retry_policy
559
+
560
+ @bigtable_stub.call_rpc :check_and_mutate_row, request, options: options do |response, operation|
561
+ yield response, operation if block_given?
562
+ return response
563
+ end
564
+ rescue ::GRPC::BadStatus => e
565
+ raise ::Google::Cloud::Error.from_error(e)
566
+ end
567
+
568
+ ##
569
+ # Modifies a row atomically on the server. The method reads the latest
570
+ # existing timestamp and value from the specified columns and writes a new
571
+ # entry based on pre-defined read/modify/write rules. The new value for the
572
+ # timestamp is the greater of the existing timestamp or the current server
573
+ # time. The method returns the new contents of all modified cells.
574
+ #
575
+ # @overload read_modify_write_row(request, options = nil)
576
+ # Pass arguments to `read_modify_write_row` via a request object, either of type
577
+ # {::Google::Cloud::Bigtable::V2::ReadModifyWriteRowRequest} or an equivalent Hash.
578
+ #
579
+ # @param request [::Google::Cloud::Bigtable::V2::ReadModifyWriteRowRequest, ::Hash]
580
+ # A request object representing the call parameters. Required. To specify no
581
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
582
+ # @param options [::Gapic::CallOptions, ::Hash]
583
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
584
+ #
585
+ # @overload read_modify_write_row(table_name: nil, app_profile_id: nil, row_key: nil, rules: nil)
586
+ # Pass arguments to `read_modify_write_row` via keyword arguments. Note that at
587
+ # least one keyword argument is required. To specify no parameters, or to keep all
588
+ # the default parameter values, pass an empty Hash as a request object (see above).
589
+ #
590
+ # @param table_name [::String]
591
+ # Required. The unique name of the table to which the read/modify/write rules should be
592
+ # applied.
593
+ # Values are of the form
594
+ # `projects/<project>/instances/<instance>/tables/<table>`.
595
+ # @param app_profile_id [::String]
596
+ # This value specifies routing for replication. If not specified, the
597
+ # "default" application profile will be used.
598
+ # @param row_key [::String]
599
+ # Required. The key of the row to which the read/modify/write rules should be applied.
600
+ # @param rules [::Array<::Google::Cloud::Bigtable::V2::ReadModifyWriteRule, ::Hash>]
601
+ # Required. Rules specifying how the specified row's contents are to be transformed
602
+ # into writes. Entries are applied in order, meaning that earlier rules will
603
+ # affect the results of later ones.
604
+ #
605
+ # @yield [response, operation] Access the result along with the RPC operation
606
+ # @yieldparam response [::Google::Cloud::Bigtable::V2::ReadModifyWriteRowResponse]
607
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
608
+ #
609
+ # @return [::Google::Cloud::Bigtable::V2::ReadModifyWriteRowResponse]
610
+ #
611
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
612
+ #
613
+ def read_modify_write_row request, options = nil
614
+ raise ::ArgumentError, "request must be provided" if request.nil?
615
+
616
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Bigtable::V2::ReadModifyWriteRowRequest
617
+
618
+ # Converts hash and nil to an options object
619
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
620
+
621
+ # Customize the options with defaults
622
+ metadata = @config.rpcs.read_modify_write_row.metadata.to_h
623
+
624
+ # Set x-goog-api-client and x-goog-user-project headers
625
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
626
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
627
+ gapic_version: ::Google::Cloud::Bigtable::V2::VERSION
628
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
629
+
630
+ header_params = {
631
+ "table_name" => request.table_name
632
+ }
633
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
634
+ metadata[:"x-goog-request-params"] ||= request_params_header
635
+
636
+ options.apply_defaults timeout: @config.rpcs.read_modify_write_row.timeout,
637
+ metadata: metadata,
638
+ retry_policy: @config.rpcs.read_modify_write_row.retry_policy
639
+ options.apply_defaults metadata: @config.metadata,
640
+ retry_policy: @config.retry_policy
641
+
642
+ @bigtable_stub.call_rpc :read_modify_write_row, request, options: options do |response, operation|
643
+ yield response, operation if block_given?
644
+ return response
645
+ end
646
+ rescue ::GRPC::BadStatus => e
647
+ raise ::Google::Cloud::Error.from_error(e)
648
+ end
649
+
650
+ ##
651
+ # Configuration class for the Bigtable API.
652
+ #
653
+ # This class represents the configuration for Bigtable,
654
+ # providing control over timeouts, retry behavior, logging, transport
655
+ # parameters, and other low-level controls. Certain parameters can also be
656
+ # applied individually to specific RPCs. See
657
+ # {::Google::Cloud::Bigtable::V2::Bigtable::Client::Configuration::Rpcs}
658
+ # for a list of RPCs that can be configured independently.
659
+ #
660
+ # Configuration can be applied globally to all clients, or to a single client
661
+ # on construction.
662
+ #
663
+ # # Examples
664
+ #
665
+ # To modify the global config, setting the timeout for read_rows
666
+ # to 20 seconds, and all remaining timeouts to 10 seconds:
667
+ #
668
+ # ::Google::Cloud::Bigtable::V2::Bigtable::Client.configure do |config|
669
+ # config.timeout = 10.0
670
+ # config.rpcs.read_rows.timeout = 20.0
671
+ # end
672
+ #
673
+ # To apply the above configuration only to a new client:
674
+ #
675
+ # client = ::Google::Cloud::Bigtable::V2::Bigtable::Client.new do |config|
676
+ # config.timeout = 10.0
677
+ # config.rpcs.read_rows.timeout = 20.0
678
+ # end
679
+ #
680
+ # @!attribute [rw] endpoint
681
+ # The hostname or hostname:port of the service endpoint.
682
+ # Defaults to `"bigtable.googleapis.com"`.
683
+ # @return [::String]
684
+ # @!attribute [rw] credentials
685
+ # Credentials to send with calls. You may provide any of the following types:
686
+ # * (`String`) The path to a service account key file in JSON format
687
+ # * (`Hash`) A service account key as a Hash
688
+ # * (`Google::Auth::Credentials`) A googleauth credentials object
689
+ # (see the [googleauth docs](https://googleapis.dev/ruby/googleauth/latest/index.html))
690
+ # * (`Signet::OAuth2::Client`) A signet oauth2 client object
691
+ # (see the [signet docs](https://googleapis.dev/ruby/signet/latest/Signet/OAuth2/Client.html))
692
+ # * (`GRPC::Core::Channel`) a gRPC channel with included credentials
693
+ # * (`GRPC::Core::ChannelCredentials`) a gRPC credentails object
694
+ # * (`nil`) indicating no credentials
695
+ # @return [::Object]
696
+ # @!attribute [rw] scope
697
+ # The OAuth scopes
698
+ # @return [::Array<::String>]
699
+ # @!attribute [rw] lib_name
700
+ # The library name as recorded in instrumentation and logging
701
+ # @return [::String]
702
+ # @!attribute [rw] lib_version
703
+ # The library version as recorded in instrumentation and logging
704
+ # @return [::String]
705
+ # @!attribute [rw] channel_args
706
+ # Extra parameters passed to the gRPC channel. Note: this is ignored if a
707
+ # `GRPC::Core::Channel` object is provided as the credential.
708
+ # @return [::Hash]
709
+ # @!attribute [rw] interceptors
710
+ # An array of interceptors that are run before calls are executed.
711
+ # @return [::Array<::GRPC::ClientInterceptor>]
712
+ # @!attribute [rw] timeout
713
+ # The call timeout in seconds.
714
+ # @return [::Numeric]
715
+ # @!attribute [rw] metadata
716
+ # Additional gRPC headers to be sent with the call.
717
+ # @return [::Hash{::Symbol=>::String}]
718
+ # @!attribute [rw] retry_policy
719
+ # The retry policy. The value is a hash with the following keys:
720
+ # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
721
+ # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
722
+ # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
723
+ # * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
724
+ # trigger a retry.
725
+ # @return [::Hash]
726
+ # @!attribute [rw] quota_project
727
+ # A separate project against which to charge quota.
728
+ # @return [::String]
729
+ #
730
+ class Configuration
731
+ extend ::Gapic::Config
732
+
733
+ config_attr :endpoint, "bigtable.googleapis.com", ::String
734
+ config_attr :credentials, nil do |value|
735
+ allowed = [::String, ::Hash, ::Proc, ::Google::Auth::Credentials, ::Signet::OAuth2::Client, nil]
736
+ allowed += [::GRPC::Core::Channel, ::GRPC::Core::ChannelCredentials] if defined? ::GRPC
737
+ allowed.any? { |klass| klass === value }
738
+ end
739
+ config_attr :scope, nil, ::String, ::Array, nil
740
+ config_attr :lib_name, nil, ::String, nil
741
+ config_attr :lib_version, nil, ::String, nil
742
+ config_attr(:channel_args, { "grpc.service_config_disable_resolution"=>1 }, ::Hash, nil)
743
+ config_attr :interceptors, nil, ::Array, nil
744
+ config_attr :timeout, nil, ::Numeric, nil
745
+ config_attr :metadata, nil, ::Hash, nil
746
+ config_attr :retry_policy, nil, ::Hash, ::Proc, nil
747
+ config_attr :quota_project, nil, ::String, nil
748
+
749
+ # @private
750
+ def initialize parent_config = nil
751
+ @parent_config = parent_config unless parent_config.nil?
752
+
753
+ yield self if block_given?
754
+ end
755
+
756
+ ##
757
+ # Configurations for individual RPCs
758
+ # @return [Rpcs]
759
+ #
760
+ def rpcs
761
+ @rpcs ||= begin
762
+ parent_rpcs = nil
763
+ parent_rpcs = @parent_config.rpcs if defined?(@parent_config) && @parent_config&.respond_to?(:rpcs)
764
+ Rpcs.new parent_rpcs
765
+ end
766
+ end
767
+
768
+ ##
769
+ # Configuration RPC class for the Bigtable API.
770
+ #
771
+ # Includes fields providing the configuration for each RPC in this service.
772
+ # Each configuration object is of type `Gapic::Config::Method` and includes
773
+ # the following configuration fields:
774
+ #
775
+ # * `timeout` (*type:* `Numeric`) - The call timeout in milliseconds
776
+ # * `metadata` (*type:* `Hash{Symbol=>String}`) - Additional gRPC headers
777
+ # * `retry_policy (*type:* `Hash`) - The retry policy. The policy fields
778
+ # include the following keys:
779
+ # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
780
+ # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
781
+ # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
782
+ # * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
783
+ # trigger a retry.
784
+ #
785
+ class Rpcs
786
+ ##
787
+ # RPC-specific configuration for `read_rows`
788
+ # @return [::Gapic::Config::Method]
789
+ #
790
+ attr_reader :read_rows
791
+ ##
792
+ # RPC-specific configuration for `sample_row_keys`
793
+ # @return [::Gapic::Config::Method]
794
+ #
795
+ attr_reader :sample_row_keys
796
+ ##
797
+ # RPC-specific configuration for `mutate_row`
798
+ # @return [::Gapic::Config::Method]
799
+ #
800
+ attr_reader :mutate_row
801
+ ##
802
+ # RPC-specific configuration for `mutate_rows`
803
+ # @return [::Gapic::Config::Method]
804
+ #
805
+ attr_reader :mutate_rows
806
+ ##
807
+ # RPC-specific configuration for `check_and_mutate_row`
808
+ # @return [::Gapic::Config::Method]
809
+ #
810
+ attr_reader :check_and_mutate_row
811
+ ##
812
+ # RPC-specific configuration for `read_modify_write_row`
813
+ # @return [::Gapic::Config::Method]
814
+ #
815
+ attr_reader :read_modify_write_row
816
+
817
+ # @private
818
+ def initialize parent_rpcs = nil
819
+ read_rows_config = parent_rpcs&.read_rows if parent_rpcs&.respond_to? :read_rows
820
+ @read_rows = ::Gapic::Config::Method.new read_rows_config
821
+ sample_row_keys_config = parent_rpcs&.sample_row_keys if parent_rpcs&.respond_to? :sample_row_keys
822
+ @sample_row_keys = ::Gapic::Config::Method.new sample_row_keys_config
823
+ mutate_row_config = parent_rpcs&.mutate_row if parent_rpcs&.respond_to? :mutate_row
824
+ @mutate_row = ::Gapic::Config::Method.new mutate_row_config
825
+ mutate_rows_config = parent_rpcs&.mutate_rows if parent_rpcs&.respond_to? :mutate_rows
826
+ @mutate_rows = ::Gapic::Config::Method.new mutate_rows_config
827
+ check_and_mutate_row_config = parent_rpcs&.check_and_mutate_row if parent_rpcs&.respond_to? :check_and_mutate_row
828
+ @check_and_mutate_row = ::Gapic::Config::Method.new check_and_mutate_row_config
829
+ read_modify_write_row_config = parent_rpcs&.read_modify_write_row if parent_rpcs&.respond_to? :read_modify_write_row
830
+ @read_modify_write_row = ::Gapic::Config::Method.new read_modify_write_row_config
831
+
832
+ yield self if block_given?
833
+ end
834
+ end
835
+ end
836
+ end
837
+ end
838
+ end
839
+ end
840
+ end
841
+ end