google-cloud-bigtable 1.3.0 → 2.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (87) hide show
  1. checksums.yaml +4 -4
  2. data/AUTHENTICATION.md +1 -1
  3. data/CHANGELOG.md +54 -0
  4. data/CONTRIBUTING.md +1 -1
  5. data/OVERVIEW.md +4 -4
  6. data/lib/google-cloud-bigtable.rb +30 -27
  7. data/lib/google/cloud/bigtable.rb +18 -26
  8. data/lib/google/cloud/bigtable/app_profile.rb +3 -3
  9. data/lib/google/cloud/bigtable/app_profile/list.rb +4 -2
  10. data/lib/google/cloud/bigtable/backup.rb +123 -2
  11. data/lib/google/cloud/bigtable/backup/list.rb +2 -2
  12. data/lib/google/cloud/bigtable/chunk_processor.rb +1 -1
  13. data/lib/google/cloud/bigtable/cluster.rb +2 -2
  14. data/lib/google/cloud/bigtable/cluster/list.rb +1 -1
  15. data/lib/google/cloud/bigtable/column_family.rb +2 -2
  16. data/lib/google/cloud/bigtable/column_family_map.rb +10 -10
  17. data/lib/google/cloud/bigtable/column_range.rb +2 -2
  18. data/lib/google/cloud/bigtable/convert.rb +12 -0
  19. data/lib/google/cloud/bigtable/credentials.rb +36 -2
  20. data/lib/google/cloud/bigtable/gc_rule.rb +7 -7
  21. data/lib/google/cloud/bigtable/instance.rb +8 -8
  22. data/lib/google/cloud/bigtable/instance/cluster_map.rb +1 -1
  23. data/lib/google/cloud/bigtable/instance/list.rb +1 -1
  24. data/lib/google/cloud/bigtable/longrunning_job.rb +2 -2
  25. data/lib/google/cloud/bigtable/mutation_entry.rb +22 -18
  26. data/lib/google/cloud/bigtable/mutation_operations.rb +6 -6
  27. data/lib/google/cloud/bigtable/project.rb +1 -1
  28. data/lib/google/cloud/bigtable/read_modify_write_rule.rb +2 -2
  29. data/lib/google/cloud/bigtable/read_operations.rb +2 -2
  30. data/lib/google/cloud/bigtable/routing_policy.rb +2 -2
  31. data/lib/google/cloud/bigtable/row_filter/chain_filter.rb +3 -3
  32. data/lib/google/cloud/bigtable/row_filter/condition_filter.rb +3 -3
  33. data/lib/google/cloud/bigtable/row_filter/interleave_filter.rb +3 -3
  34. data/lib/google/cloud/bigtable/row_filter/simple_filter.rb +9 -4
  35. data/lib/google/cloud/bigtable/row_range.rb +2 -2
  36. data/lib/google/cloud/bigtable/rows_mutator.rb +3 -3
  37. data/lib/google/cloud/bigtable/rows_reader.rb +10 -10
  38. data/lib/google/cloud/bigtable/sample_row_key.rb +2 -2
  39. data/lib/google/cloud/bigtable/service.rb +239 -281
  40. data/lib/google/cloud/bigtable/table.rb +5 -4
  41. data/lib/google/cloud/bigtable/table/cluster_state.rb +2 -2
  42. data/lib/google/cloud/bigtable/table/list.rb +1 -1
  43. data/lib/google/cloud/bigtable/value_range.rb +26 -8
  44. data/lib/google/cloud/bigtable/version.rb +1 -1
  45. metadata +12 -94
  46. data/lib/google/bigtable/admin/v2/bigtable_instance_admin_pb.rb +0 -145
  47. data/lib/google/bigtable/admin/v2/bigtable_instance_admin_services_pb.rb +0 -90
  48. data/lib/google/bigtable/admin/v2/bigtable_table_admin_pb.rb +0 -208
  49. data/lib/google/bigtable/admin/v2/bigtable_table_admin_services_pb.rb +0 -154
  50. data/lib/google/bigtable/admin/v2/common_pb.rb +0 -30
  51. data/lib/google/bigtable/admin/v2/instance_pb.rb +0 -74
  52. data/lib/google/bigtable/admin/v2/table_pb.rb +0 -127
  53. data/lib/google/bigtable/v2/bigtable_pb.rb +0 -113
  54. data/lib/google/bigtable/v2/bigtable_services_pb.rb +0 -68
  55. data/lib/google/bigtable/v2/data_pb.rb +0 -156
  56. data/lib/google/cloud/bigtable/admin.rb +0 -202
  57. data/lib/google/cloud/bigtable/admin/credentials.rb +0 -27
  58. data/lib/google/cloud/bigtable/admin/v2.rb +0 -223
  59. data/lib/google/cloud/bigtable/admin/v2/bigtable_instance_admin_client.rb +0 -1451
  60. data/lib/google/cloud/bigtable/admin/v2/bigtable_instance_admin_client_config.json +0 -139
  61. data/lib/google/cloud/bigtable/admin/v2/bigtable_table_admin_client.rb +0 -1734
  62. data/lib/google/cloud/bigtable/admin/v2/bigtable_table_admin_client_config.json +0 -163
  63. data/lib/google/cloud/bigtable/admin/v2/credentials.rb +0 -51
  64. data/lib/google/cloud/bigtable/admin/v2/doc/google/bigtable/admin/v2/bigtable_instance_admin.rb +0 -297
  65. data/lib/google/cloud/bigtable/admin/v2/doc/google/bigtable/admin/v2/bigtable_table_admin.rb +0 -587
  66. data/lib/google/cloud/bigtable/admin/v2/doc/google/bigtable/admin/v2/instance.rb +0 -193
  67. data/lib/google/cloud/bigtable/admin/v2/doc/google/bigtable/admin/v2/table.rb +0 -303
  68. data/lib/google/cloud/bigtable/admin/v2/doc/google/iam/v1/iam_policy.rb +0 -64
  69. data/lib/google/cloud/bigtable/admin/v2/doc/google/iam/v1/options.rb +0 -33
  70. data/lib/google/cloud/bigtable/admin/v2/doc/google/iam/v1/policy.rb +0 -151
  71. data/lib/google/cloud/bigtable/admin/v2/doc/google/longrunning/operations.rb +0 -51
  72. data/lib/google/cloud/bigtable/admin/v2/doc/google/protobuf/any.rb +0 -131
  73. data/lib/google/cloud/bigtable/admin/v2/doc/google/protobuf/duration.rb +0 -91
  74. data/lib/google/cloud/bigtable/admin/v2/doc/google/protobuf/empty.rb +0 -29
  75. data/lib/google/cloud/bigtable/admin/v2/doc/google/protobuf/field_mask.rb +0 -222
  76. data/lib/google/cloud/bigtable/admin/v2/doc/google/protobuf/timestamp.rb +0 -113
  77. data/lib/google/cloud/bigtable/admin/v2/doc/google/rpc/status.rb +0 -39
  78. data/lib/google/cloud/bigtable/admin/v2/doc/google/type/expr.rb +0 -45
  79. data/lib/google/cloud/bigtable/v2.rb +0 -146
  80. data/lib/google/cloud/bigtable/v2/bigtable_client.rb +0 -591
  81. data/lib/google/cloud/bigtable/v2/bigtable_client_config.json +0 -83
  82. data/lib/google/cloud/bigtable/v2/credentials.rb +0 -46
  83. data/lib/google/cloud/bigtable/v2/doc/google/bigtable/v2/bigtable.rb +0 -290
  84. data/lib/google/cloud/bigtable/v2/doc/google/bigtable/v2/data.rb +0 -493
  85. data/lib/google/cloud/bigtable/v2/doc/google/protobuf/any.rb +0 -131
  86. data/lib/google/cloud/bigtable/v2/doc/google/protobuf/wrappers.rb +0 -34
  87. data/lib/google/cloud/bigtable/v2/doc/google/rpc/status.rb +0 -39
@@ -65,8 +65,8 @@ module Google
65
65
  #
66
66
  # entry = table.new_mutation_entry("user-1")
67
67
  # entry.set_cell(
68
- # "cf-1",
69
- # "field-1",
68
+ # "cf1",
69
+ # "field1",
70
70
  # "XYZ",
71
71
  # timestamp: (Time.now.to_f * 1000000).round(-3) # microseconds
72
72
  # ).delete_cells("cf2", "field02")
@@ -89,7 +89,7 @@ module Google
89
89
  # applied in arbitrary order (even between entries for the same row).
90
90
  # At least one entry must be specified, and in total the entries can
91
91
  # contain a maximum of 100,000 mutations.
92
- # @return [Array<Google::Bigtable::V2::MutateRowsResponse::Entry>]
92
+ # @return [Array<Google::Cloud::Bigtable::V2::MutateRowsResponse::Entry>]
93
93
  #
94
94
  # @example
95
95
  # require "google/cloud/bigtable"
@@ -219,8 +219,8 @@ module Google
219
219
  # predicate_filter = Google::Cloud::Bigtable::RowFilter.key("user-10")
220
220
  # on_match_mutations = Google::Cloud::Bigtable::MutationEntry.new
221
221
  # on_match_mutations.set_cell(
222
- # "cf-1",
223
- # "field-1",
222
+ # "cf1",
223
+ # "field1",
224
224
  # "XYZ",
225
225
  # timestamp: (Time.now.to_f * 1000000).round(-3) # microseconds
226
226
  # ).delete_cells("cf2", "field02")
@@ -346,7 +346,7 @@ module Google
346
346
 
347
347
  ##
348
348
  # @private New MutationEntry::Response from a
349
- # Google::Bigtable::V2::MutateRowsResponse::Entry object.
349
+ # Google::Cloud::Bigtable::V2::MutateRowsResponse::Entry object.
350
350
  def self.from_grpc grpc
351
351
  new grpc.index, Status.from_grpc(grpc.status)
352
352
  end
@@ -227,7 +227,7 @@ module Google
227
227
  labels = Hash[labels.map { |k, v| [String(k), String(v)] }] if labels
228
228
 
229
229
  instance_attrs = { display_name: display_name, type: type, labels: labels }.delete_if { |_, v| v.nil? }
230
- instance = Google::Bigtable::Admin::V2::Instance.new instance_attrs
230
+ instance = Google::Cloud::Bigtable::Admin::V2::Instance.new instance_attrs
231
231
  clusters ||= Instance::ClusterMap.new
232
232
  yield clusters if block_given?
233
233
 
@@ -44,7 +44,7 @@ module Google
44
44
  # The qualifier of the column to which the read/modify/write should be applied.
45
45
  #
46
46
  def initialize family, qualifier
47
- @grpc = Google::Bigtable::V2::ReadModifyWriteRule.new
47
+ @grpc = Google::Cloud::Bigtable::V2::ReadModifyWriteRule.new
48
48
  @grpc.family_name = family
49
49
  @grpc.column_qualifier = qualifier
50
50
  end
@@ -123,7 +123,7 @@ module Google
123
123
  #
124
124
  # Get gRPC protobuf instance.
125
125
  #
126
- # @return [Google::Bigtable::V2::ReadModifyWriteRule]
126
+ # @return [Google::Cloud::Bigtable::V2::ReadModifyWriteRule]
127
127
  #
128
128
  def to_grpc
129
129
  @grpc
@@ -309,7 +309,7 @@ module Google
309
309
  #
310
310
  # @param row_keys [Array<String>]
311
311
  # @param row_ranges [Google::Cloud::Bigtable::RowRange | Array<Google::Cloud::Bigtable::RowRange>]
312
- # @return [Google::Bigtable::V2::RowSet]
312
+ # @return [Google::Cloud::Bigtable::V2::RowSet]
313
313
  #
314
314
  def build_row_set row_keys, row_ranges
315
315
  row_set = {}
@@ -320,7 +320,7 @@ module Google
320
320
  row_set[:row_ranges] = row_ranges.map(&:to_grpc)
321
321
  end
322
322
 
323
- Google::Bigtable::V2::RowSet.new row_set
323
+ Google::Cloud::Bigtable::V2::RowSet.new row_set
324
324
  end
325
325
  end
326
326
  end
@@ -99,7 +99,7 @@ module Google
99
99
  class MultiClusterRoutingUseAny < RoutingPolicy
100
100
  # @private
101
101
  def to_grpc
102
- Google::Bigtable::Admin::V2::AppProfile::MultiClusterRoutingUseAny.new
102
+ Google::Cloud::Bigtable::Admin::V2::AppProfile::MultiClusterRoutingUseAny.new
103
103
  end
104
104
  end
105
105
 
@@ -161,7 +161,7 @@ module Google
161
161
 
162
162
  # @private
163
163
  def to_grpc
164
- Google::Bigtable::Admin::V2::AppProfile::SingleClusterRouting.new(
164
+ Google::Cloud::Bigtable::Admin::V2::AppProfile::SingleClusterRouting.new(
165
165
  cluster_id: cluster_id,
166
166
  allow_transactional_writes: allow_transactional_writes
167
167
  )
@@ -564,11 +564,11 @@ module Google
564
564
  #
565
565
  # Gets a gRPC object of RowFilter with a chain filter.
566
566
  #
567
- # @return [Google::Bigtable::V2::RowFilter]
567
+ # @return [Google::Cloud::Bigtable::V2::RowFilter]
568
568
  #
569
569
  def to_grpc
570
- Google::Bigtable::V2::RowFilter.new(
571
- chain: Google::Bigtable::V2::RowFilter::Chain.new(filters: @filters.map(&:to_grpc))
570
+ Google::Cloud::Bigtable::V2::RowFilter.new(
571
+ chain: Google::Cloud::Bigtable::V2::RowFilter::Chain.new(filters: @filters.map(&:to_grpc))
572
572
  )
573
573
  end
574
574
 
@@ -48,7 +48,7 @@ module Google
48
48
  # @param predicate [SimpleFilter, ChainFilter, InterleaveFilter, ConditionFilter]
49
49
  #
50
50
  def initialize predicate
51
- @grpc = Google::Bigtable::V2::RowFilter::Condition.new
51
+ @grpc = Google::Cloud::Bigtable::V2::RowFilter::Condition.new
52
52
  @grpc.predicate_filter = predicate.to_grpc
53
53
  end
54
54
 
@@ -102,10 +102,10 @@ module Google
102
102
 
103
103
  # @private
104
104
  # Gets the row-filter gRPC instance.
105
- # @return [Google::Bigtable::V2::RowFilter]
105
+ # @return [Google::Cloud::Bigtable::V2::RowFilter]
106
106
  #
107
107
  def to_grpc
108
- Google::Bigtable::V2::RowFilter.new condition: @grpc
108
+ Google::Cloud::Bigtable::V2::RowFilter.new condition: @grpc
109
109
  end
110
110
  end
111
111
  end
@@ -595,11 +595,11 @@ module Google
595
595
  #
596
596
  # Gets a gRPC object of RowFilter with interleave filter.
597
597
  #
598
- # @return [Google::Bigtable::V2::RowFilter]
598
+ # @return [Google::Cloud::Bigtable::V2::RowFilter]
599
599
  #
600
600
  def to_grpc
601
- Google::Bigtable::V2::RowFilter.new(
602
- interleave: Google::Bigtable::V2::RowFilter::Interleave.new(filters: @filters.map(&:to_grpc))
601
+ Google::Cloud::Bigtable::V2::RowFilter.new(
602
+ interleave: Google::Cloud::Bigtable::V2::RowFilter::Interleave.new(filters: @filters.map(&:to_grpc))
603
603
  )
604
604
  end
605
605
 
@@ -15,6 +15,8 @@
15
15
  # limitations under the License.
16
16
 
17
17
 
18
+ require "google/cloud/bigtable/convert"
19
+
18
20
  module Google
19
21
  module Cloud
20
22
  module Bigtable
@@ -28,7 +30,7 @@ module Google
28
30
  # Creates a simple filter instance.
29
31
  #
30
32
  def initialize
31
- @grpc = Google::Bigtable::V2::RowFilter.new
33
+ @grpc = Google::Cloud::Bigtable::V2::RowFilter.new
32
34
  end
33
35
 
34
36
  ##
@@ -147,10 +149,13 @@ module Google
147
149
  # will not match the new line character `\n`, which may be present in a
148
150
  # binary value.
149
151
  #
150
- # @param regex [String] Regex to match cell value.
152
+ # @param regex [String, Integer] Regex to match cell value, or an Integer
153
+ # value to be encoded as a 64-bit signed big-endian integer.
151
154
  # @return [Google::Cloud::Bigtable::RowFilter::SimpleFilter]
152
155
  #
153
156
  def value regex
157
+ # If regex is integer, covert it to a 64-bit signed big-endian integer.
158
+ regex = Convert.integer_to_signed_be_64 regex
154
159
  @grpc.value_regex_filter = regex
155
160
  self
156
161
  end
@@ -230,7 +235,7 @@ module Google
230
235
  # @return [Google::Cloud::Bigtable::RowFilter::SimpleFilter]
231
236
  #
232
237
  def timestamp_range from, to
233
- range_grpc = Google::Bigtable::V2::TimestampRange.new
238
+ range_grpc = Google::Cloud::Bigtable::V2::TimestampRange.new
234
239
  range_grpc.start_timestamp_micros = from if from
235
240
  range_grpc.end_timestamp_micros = to if to
236
241
  @grpc.timestamp_range_filter = range_grpc
@@ -276,7 +281,7 @@ module Google
276
281
  #
277
282
  # Converts to a gRPC row filter instance.
278
283
  #
279
- # @return [Google::Bigtable::V2::RowFilter]
284
+ # @return [Google::Cloud::Bigtable::V2::RowFilter]
280
285
  def to_grpc
281
286
  @grpc
282
287
  end
@@ -57,7 +57,7 @@ module Google
57
57
  # @private
58
58
  # Creates a row range instance.
59
59
  def initialize
60
- @grpc = Google::Bigtable::V2::RowRange.new
60
+ @grpc = Google::Cloud::Bigtable::V2::RowRange.new
61
61
  end
62
62
 
63
63
  ##
@@ -168,7 +168,7 @@ module Google
168
168
 
169
169
  # @private
170
170
  #
171
- # @return [Google::Bigtable::V2::RowRange]
171
+ # @return [Google::Cloud::Bigtable::V2::RowRange]
172
172
  #
173
173
  def to_grpc
174
174
  @grpc
@@ -53,7 +53,7 @@ module Google
53
53
  ##
54
54
  # Applies mutations.
55
55
  #
56
- # @return [Array<Google::Bigtable::V2::MutateRowsResponse::Entry>]
56
+ # @return [Array<Google::Cloud::Bigtable::V2::MutateRowsResponse::Entry>]
57
57
  #
58
58
  def apply_mutations
59
59
  @req_entries = @entries.map(&:to_grpc)
@@ -80,7 +80,7 @@ module Google
80
80
  # Mutates rows.
81
81
  #
82
82
  # @param entries [Array<Google::Cloud::Bigtable::MutationEntry>]
83
- # @return [Array<Google::Bigtable::V2::MutateRowsResponse::Entry>]
83
+ # @return [Array<Google::Cloud::Bigtable::V2::MutateRowsResponse::Entry>]
84
84
  #
85
85
  def mutate_rows entries
86
86
  response = @table.service.mutate_rows @table.path, entries, app_profile_id: @table.app_profile_id
@@ -92,7 +92,7 @@ module Google
92
92
  ##
93
93
  # Collects failed entries, retries mutation, and updates status.
94
94
  #
95
- # @param statuses [Array<Google::Bigtable::V2::MutateRowsResponse::Entry>]
95
+ # @param statuses [Array<Google::Cloud::Bigtable::V2::MutateRowsResponse::Entry>]
96
96
  # @param indices [Array<Integer>]
97
97
  # Retry entries position mapping list
98
98
  # @return [Array<Integer>]
@@ -59,14 +59,14 @@ module Google
59
59
  ##
60
60
  # Read rows
61
61
  #
62
- # @param rows [Google::Bigtable::V2::RowSet]
62
+ # @param rows [Google::Cloud::Bigtable::V2::RowSet]
63
63
  # The row keys and/or ranges to read.
64
64
  # If not specified, reads from all rows.
65
- # Alternatively, provide a hash in the form of `Google::Bigtable::V2::RowSet`.
66
- # @param filter [Google::Bigtable::V2::RowFilter | Hash]
65
+ # Alternatively, provide a hash in the form of `Google::Cloud::Bigtable::V2::RowSet`.
66
+ # @param filter [Google::Cloud::Bigtable::V2::RowFilter | Hash]
67
67
  # The filter to apply to the contents of the specified row(s). If unset,
68
68
  # reads the entirety of each row.
69
- # A hash in the form of `Google::Bigtable::V2::RowFilter`
69
+ # A hash in the form of `Google::Cloud::Bigtable::V2::RowFilter`
70
70
  # can also be provided.
71
71
  # @param rows_limit [Integer]
72
72
  # The read will terminate after committing to N rows' worth of results.
@@ -111,12 +111,12 @@ module Google
111
111
  # @param rows_limit [Integer]
112
112
  # The read will terminate after committing to N rows' worth of results.
113
113
  # The default (zero) is to return all results.
114
- # @param row_set [Google::Bigtable::V2::RowSet]
114
+ # @param row_set [Google::Cloud::Bigtable::V2::RowSet]
115
115
  # The row keys and/or ranges to read.
116
116
  # If not specified, reads from all rows.
117
- # A hash of the same form as `Google::Bigtable::V2::RowSet`
117
+ # A hash of the same form as `Google::Cloud::Bigtable::V2::RowSet`
118
118
  # can also be provided.
119
- # @return [Integer, Google::Bigtable::V2::RowSet]
119
+ # @return [Integer, Google::Cloud::Bigtable::V2::RowSet]
120
120
  #
121
121
  def retry_options rows_limit, row_set
122
122
  return [rows_limit, row_set] unless last_key
@@ -142,7 +142,7 @@ module Google
142
142
 
143
143
  if row_set.row_ranges.empty?
144
144
  row_set.row_ranges <<
145
- Google::Bigtable::V2::RowRange.new(start_key_open: last_key)
145
+ Google::Cloud::Bigtable::V2::RowRange.new(start_key_open: last_key)
146
146
  end
147
147
 
148
148
  # 3. Remove all individual keys before and up to the last read key
@@ -166,7 +166,7 @@ module Google
166
166
  ##
167
167
  # Checks if the start key was already read for the range.
168
168
  #
169
- # @param range [Google::Bigtable::V2::RowRange]
169
+ # @param range [Google::Cloud::Bigtable::V2::RowRange]
170
170
  # @return [Boolean]
171
171
  #
172
172
  def start_key_read? range
@@ -182,7 +182,7 @@ module Google
182
182
  ##
183
183
  # Checks if the end key was already read for the range.
184
184
  #
185
- # @param range [Google::Bigtable::V2::RowRange]
185
+ # @param range [Google::Cloud::Bigtable::V2::RowRange]
186
186
  # @return [Boolean]
187
187
  #
188
188
  def end_key_read? range
@@ -72,8 +72,8 @@ module Google
72
72
  # @private
73
73
  #
74
74
  # Creates a new SampleRowKey instance from a
75
- # Google::Bigtable::V2::SampleRowKey.
76
- # @param grpc [Google::Bigtable::V2::SampleRowKeysResponse]
75
+ # Google::Cloud::Bigtable::V2::SampleRowKey.
76
+ # @param grpc [Google::Cloud::Bigtable::V2::SampleRowKeysResponse]
77
77
  # @return [Google::Cloud::Bigtable::SampleRowKey]
78
78
  #
79
79
  def self.from_grpc grpc
@@ -18,9 +18,8 @@
18
18
  require "google/cloud/bigtable/version"
19
19
  require "google/cloud/bigtable/errors"
20
20
  require "google/cloud/bigtable/credentials"
21
- require "google/cloud/bigtable/admin/v2/bigtable_instance_admin_client"
22
- require "google/cloud/bigtable/admin/v2/bigtable_table_admin_client"
23
- require "google/cloud/bigtable/v2/bigtable_client"
21
+ require "google/cloud/bigtable/v2"
22
+ require "google/cloud/bigtable/admin/v2"
24
23
 
25
24
  module Google
26
25
  module Cloud
@@ -29,7 +28,7 @@ module Google
29
28
  # gRPC Cloud Bigtable service, including API methods.
30
29
  class Service
31
30
  # @private
32
- attr_accessor :project_id, :credentials, :host, :timeout, :client_config
31
+ attr_accessor :project_id, :credentials, :host, :host_admin, :timeout
33
32
 
34
33
  # @private
35
34
  # Creates a new Service instance.
@@ -49,109 +48,74 @@ module Google
49
48
  # generally, to give OAuth credentials.
50
49
  # @param timeout [Integer]
51
50
  # The default timeout, in seconds, for calls made through this client.
52
- # @param client_config [Hash]
53
- # A hash for call options for each method. See Google::Gax#construct_settings for the structure of this data.
54
- # Falls back to the default config if not specified or the specified config is missing data points.
55
51
  #
56
- def initialize project_id, credentials, host: nil, timeout: nil, client_config: nil
52
+ def initialize project_id, credentials, host: nil, host_admin: nil, timeout: nil
57
53
  @project_id = project_id
58
54
  @credentials = credentials
59
55
  @host = host
56
+ @host_admin = host_admin
60
57
  @timeout = timeout
61
- @client_config = client_config || {}
62
58
  end
63
59
 
64
- def channel default_host
65
- require "grpc"
66
- GRPC::Core::Channel.new((host || default_host), chan_args, chan_creds)
67
- end
68
-
69
- def chan_args
70
- { "grpc.max_send_message_length" => -1,
71
- "grpc.max_receive_message_length" => -1,
72
- "grpc.service_config_disable_resolution" => 1 }
73
- end
74
-
75
- def chan_creds
76
- return credentials if insecure?
77
- require "grpc"
78
- GRPC::Core::ChannelCredentials.new.compose GRPC::Core::CallCredentials.new credentials.client.updater_proc
79
- end
80
-
81
- ##
82
- # Creates or returns an instance of an instance admin client.
83
- #
84
- # @return [Google::Cloud::Bigtable::Admin::V2::BigtableInstanceAdminClient]
85
- #
86
60
  def instances
87
61
  return mocked_instances if mocked_instances
88
- @instances ||= Admin::V2::BigtableInstanceAdminClient.new(
89
- credentials: channel(Admin::V2::BigtableInstanceAdminClient::SERVICE_ADDRESS),
90
- timeout: timeout,
91
- client_config: client_config,
92
- lib_name: "gccl",
93
- lib_version: Google::Cloud::Bigtable::VERSION
94
- )
62
+ @instances ||= Admin::V2::BigtableInstanceAdmin::Client.new do |config|
63
+ config.credentials = credentials if credentials
64
+ config.timeout = timeout if timeout
65
+ config.endpoint = host_admin if host_admin
66
+ config.lib_name = "gccl"
67
+ config.lib_version = Google::Cloud::Bigtable::VERSION
68
+ config.metadata = { "google-cloud-resource-prefix": "projects/#{@project_id}" }
69
+ end
95
70
  end
96
71
  attr_accessor :mocked_instances
97
72
 
98
- ##
99
- # Creates or returns an instance of a table admin client.
100
- #
101
- # @return [Google::Cloud::Bigtable::Admin::V2::BigtableTableAdminClient]
102
- #
103
73
  def tables
104
74
  return mocked_tables if mocked_tables
105
- @tables ||= Admin::V2::BigtableTableAdminClient.new(
106
- credentials: channel(Admin::V2::BigtableTableAdminClient::SERVICE_ADDRESS),
107
- timeout: timeout,
108
- client_config: client_config,
109
- lib_name: "gccl",
110
- lib_version: Google::Cloud::Bigtable::VERSION
111
- )
75
+ @tables ||= Admin::V2::BigtableTableAdmin::Client.new do |config|
76
+ config.credentials = credentials if credentials
77
+ config.timeout = timeout if timeout
78
+ config.endpoint = host_admin if host_admin
79
+ config.lib_name = "gccl"
80
+ config.lib_version = Google::Cloud::Bigtable::VERSION
81
+ config.metadata = { "google-cloud-resource-prefix": "projects/#{@project_id}" }
82
+ end
112
83
  end
113
84
  attr_accessor :mocked_tables
114
85
 
115
- ##
116
- # Creates an instance of a data client.
117
- #
118
- # @return [Google::Cloud::Bigtable::V2::BigtableClient]
119
- #
120
86
  def client
121
87
  return mocked_client if mocked_client
122
- @client ||= V2::BigtableClient.new(
123
- credentials: channel(V2::BigtableClient::SERVICE_ADDRESS),
124
- timeout: timeout,
125
- client_config: client_config,
126
- lib_name: "gccl",
127
- lib_version: Google::Cloud::Bigtable::VERSION
128
- )
88
+ @client ||= V2::Bigtable::Client.new do |config|
89
+ config.credentials = credentials if credentials
90
+ config.timeout = timeout if timeout
91
+ config.endpoint = host if host
92
+ config.lib_name = "gccl"
93
+ config.lib_version = Google::Cloud::Bigtable::VERSION
94
+ config.metadata = { "google-cloud-resource-prefix": "projects/#{@project_id}" }
95
+ end
129
96
  end
130
97
  attr_accessor :mocked_client
131
98
 
132
- def insecure?
133
- credentials == :this_channel_is_insecure
134
- end
135
-
136
99
  ##
137
100
  # Creates an instance within a project.
138
101
  #
139
102
  # @param instance_id [String]
140
103
  # The permanent identifier to be used for the new instance.
141
104
  #
142
- # @param instance [Google::Bigtable::Admin::V2::Instance | Hash]
143
- # @param clusters [Hash{String => Google::Bigtable::Admin::V2::Cluster | Hash}]
105
+ # @param instance [Google::Cloud::Bigtable::Admin::V2::Instance | Hash]
106
+ # @param clusters [Hash{String => Google::Cloud::Bigtable::Admin::V2::Cluster | Hash}]
144
107
  # The clusters to be created in the instance.
145
108
  # Note that the cluster ID is the last segment of a cluster name. In the
146
109
  # following cluster name, 'mycluster' is the cluster ID:
147
110
  # +projects/myproject/instances/myinstance/clusters/mycluster+.
148
- # Alternatively, provide a hash in the form of `Google::Bigtable::Admin::V2::Cluster`
149
- # @return [Google::Gax::Operation]
111
+ # Alternatively, provide a hash in the form of `Google::Cloud::Bigtable::Admin::V2::Cluster`
112
+ # @return [Gapic::Operation]
150
113
  #
151
114
  def create_instance instance_id, instance, clusters
152
- execute do
153
- instances.create_instance project_path, instance_id, instance, clusters
154
- end
115
+ instances.create_instance parent: project_path,
116
+ instance_id: instance_id,
117
+ instance: instance,
118
+ clusters: clusters
155
119
  end
156
120
 
157
121
  ##
@@ -159,12 +123,10 @@ module Google
159
123
  #
160
124
  # @param token [String]
161
125
  # The value of +next_page_token+ returned by a previous call.
162
- # @return [Google::Bigtable::Admin::V2::ListInstancesResponse]
126
+ # @return [Google::Cloud::Bigtable::Admin::V2::ListInstancesResponse]
163
127
  #
164
128
  def list_instances token: nil
165
- execute do
166
- instances.list_instances project_path, page_token: token
167
- end
129
+ instances.list_instances parent: project_path, page_token: token
168
130
  end
169
131
 
170
132
  ##
@@ -172,30 +134,26 @@ module Google
172
134
  #
173
135
  # @param instance_id [String]
174
136
  # Unique ID of the requested instance.
175
- # @return [Google::Bigtable::Admin::V2::Instance]
137
+ # @return [Google::Cloud::Bigtable::Admin::V2::Instance]
176
138
  #
177
139
  def get_instance instance_id
178
- execute do
179
- instances.get_instance instance_path(instance_id)
180
- end
140
+ instances.get_instance name: instance_path(instance_id)
181
141
  end
182
142
 
183
143
  ##
184
144
  # Partially updates an instance.
185
145
  #
186
- # @param instance [Google::Bigtable::Admin::V2::Instance | Hash]
146
+ # @param instance [Google::Cloud::Bigtable::Admin::V2::Instance | Hash]
187
147
  # The instance that will (partially) replace the current value.
188
- # Alternatively, provide a hash in the form of `Google::Bigtable::Admin::V2::Instance.
148
+ # Alternatively, provide a hash in the form of `Google::Cloud::Bigtable::Admin::V2::Instance.
189
149
  # @param update_mask [Google::Protobuf::FieldMask | Hash]
190
150
  # List of instance properties to be replaced.
191
151
  # Must be explicitly set.
192
152
  # Alternatively, provide a hash in the form of `Google::Protobuf::FieldMask`.
193
- # @return [Google::Gax::Operation]
153
+ # @return [Gapic::Operation]
194
154
  #
195
155
  def partial_update_instance instance, update_mask
196
- execute do
197
- instances.partial_update_instance instance, update_mask
198
- end
156
+ instances.partial_update_instance instance: instance, update_mask: update_mask
199
157
  end
200
158
 
201
159
  ##
@@ -205,11 +163,7 @@ module Google
205
163
  # Unique ID of the instance to be deleted.
206
164
  #
207
165
  def delete_instance instance_id
208
- execute do
209
- instances.delete_instance(
210
- instance_path(instance_id)
211
- )
212
- end
166
+ instances.delete_instance name: instance_path(instance_id)
213
167
  end
214
168
 
215
169
  ##
@@ -219,18 +173,16 @@ module Google
219
173
  # Unique ID of the instance in which to create the new cluster
220
174
  # @param cluster_id [String]
221
175
  # Unique permanent identifier for the new cluster
222
- # @param cluster [Google::Bigtable::Admin::V2::Cluster | Hash]
176
+ # @param cluster [Google::Cloud::Bigtable::Admin::V2::Cluster | Hash]
223
177
  # The cluster to be created.
224
- # Alternatively, provide a hash in the form of `Google::Bigtable::Admin::V2::Cluster`
178
+ # Alternatively, provide a hash in the form of `Google::Cloud::Bigtable::Admin::V2::Cluster`
225
179
  #
226
- # @return [Google::Gax::Operation]
180
+ # @return [Gapic::Operation]
227
181
  #
228
182
  def create_cluster instance_id, cluster_id, cluster
229
183
  cluster.location = location_path cluster.location unless cluster.location == ""
230
184
 
231
- execute do
232
- instances.create_cluster instance_path(instance_id), cluster_id, cluster
233
- end
185
+ instances.create_cluster parent: instance_path(instance_id), cluster_id: cluster_id, cluster: cluster
234
186
  end
235
187
 
236
188
  ##
@@ -240,12 +192,10 @@ module Google
240
192
  # Unique ID of the instance for which a list of clusters is requested.
241
193
  # @param token [String]
242
194
  # The value of +next_page_token+ returned by a previous call.
243
- # @return [Google::Bigtable::Admin::V2::ListClustersResponse]
195
+ # @return [Google::Cloud::Bigtable::Admin::V2::ListClustersResponse]
244
196
  #
245
197
  def list_clusters instance_id, token: nil
246
- execute do
247
- instances.list_clusters instance_path(instance_id), page_token: token
248
- end
198
+ instances.list_clusters parent: instance_path(instance_id), page_token: token
249
199
  end
250
200
 
251
201
  ##
@@ -255,12 +205,10 @@ module Google
255
205
  # Unique ID of the instance the cluster is in.
256
206
  # @param cluster_id [String]
257
207
  # Unique ID of the requested cluster.
258
- # @return [Google::Bigtable::Admin::V2::Cluster]
208
+ # @return [Google::Cloud::Bigtable::Admin::V2::Cluster]
259
209
  #
260
210
  def get_cluster instance_id, cluster_id
261
- execute do
262
- instances.get_cluster cluster_path(instance_id, cluster_id)
263
- end
211
+ instances.get_cluster name: cluster_path(instance_id, cluster_id)
264
212
  end
265
213
 
266
214
  ##
@@ -278,12 +226,12 @@ module Google
278
226
  # @param serve_nodes [Integer]
279
227
  # The number of nodes allocated to this cluster. More nodes enable higher
280
228
  # throughput and more consistent performance.
281
- # @return [Google::Gax::Operation]
229
+ # @return [Gapic::Operation]
282
230
  #
283
231
  def update_cluster instance_id, cluster_id, location, serve_nodes
284
- execute do
285
- instances.update_cluster cluster_path(instance_id, cluster_id), location, serve_nodes
286
- end
232
+ instances.update_cluster name: cluster_path(instance_id, cluster_id),
233
+ location: location,
234
+ serve_nodes: serve_nodes
287
235
  end
288
236
 
289
237
  ##
@@ -295,9 +243,7 @@ module Google
295
243
  # Unique ID of the cluster to be deleted.
296
244
  #
297
245
  def delete_cluster instance_id, cluster_id
298
- execute do
299
- instances.delete_cluster cluster_path(instance_id, cluster_id)
300
- end
246
+ instances.delete_cluster name: cluster_path(instance_id, cluster_id)
301
247
  end
302
248
 
303
249
  ##
@@ -308,10 +254,10 @@ module Google
308
254
  # Unique ID of the instance to create the table in.
309
255
  # @param table_id [String]
310
256
  # Unique, permanent identifier for the new table.
311
- # @param table [Google::Bigtable::Admin::V2::Table | Hash]
257
+ # @param table [Google::Cloud::Bigtable::Admin::V2::Table | Hash]
312
258
  # The table to create.
313
- # Alternatively, provide a hash in the form of `Google::Bigtable::Admin::V2::Table`.
314
- # @param initial_splits [Array<Google::Bigtable::Admin::V2::CreateTableRequest::Split | Hash>]
259
+ # Alternatively, provide a hash in the form of `Google::Cloud::Bigtable::Admin::V2::Table`.
260
+ # @param initial_splits [Array<Google::Cloud::Bigtable::Admin::V2::CreateTableRequest::Split | Hash>]
315
261
  # The optional list of row keys that will be used to initially split the
316
262
  # table into several tablets (tablets are similar to HBase regions).
317
263
  # Given two split keys, +s1+ and +s2+, three tablets will be created,
@@ -329,15 +275,20 @@ module Google
329
275
  # * Tablet 4 +[customer_2, other) => {"customer_2"}.+
330
276
  # * Tablet 5 +[other, ) => {"other", "zz"}.+
331
277
  # Alternatively, provide a hash in the form of
332
- # `Google::Bigtable::Admin::V2::CreateTableRequest::Split`
333
- # @return [Google::Bigtable::Admin::V2::Table]
278
+ # `Google::Cloud::Bigtable::Admin::V2::CreateTableRequest::Split`
279
+ # @return [Google::Cloud::Bigtable::Admin::V2::Table]
334
280
  #
335
281
  def create_table instance_id, table_id, table, initial_splits: nil
336
282
  initial_splits = initial_splits.map { |key| { key: key } } if initial_splits
337
283
 
338
- execute do
339
- tables.create_table instance_path(instance_id), table_id, table, initial_splits: initial_splits
340
- end
284
+ tables.create_table(
285
+ {
286
+ parent: instance_path(instance_id),
287
+ table_id: table_id,
288
+ table: table,
289
+ initial_splits: initial_splits
290
+ }.delete_if { |_, v| v.nil? }
291
+ )
341
292
  end
342
293
 
343
294
  ##
@@ -345,18 +296,16 @@ module Google
345
296
  #
346
297
  # @param instance_id [String]
347
298
  # Unique ID of the instance for which tables should be listed.
348
- # @param view [Google::Bigtable::Admin::V2::Table::View]
299
+ # @param view [Google::Cloud::Bigtable::Admin::V2::Table::View]
349
300
  # View to be applied to the returned tables' fields.
350
301
  # Defaults to +NAME_ONLY+ if unspecified; no others are currently supported.
351
- # @return [Google::Gax::PagedEnumerable<Google::Bigtable::Admin::V2::Table>]
352
- # An enumerable of Google::Bigtable::Admin::V2::Table instances.
353
- # See Google::Gax::PagedEnumerable documentation for other
302
+ # @return [Gapic::PagedEnumerable<Google::Cloud::Bigtable::Admin::V2::Table>]
303
+ # An enumerable of Google::Cloud::Bigtable::Admin::V2::Table instances.
304
+ # See Gapic::PagedEnumerable documentation for other
354
305
  # operations such as per-page iteration or access to the response.
355
306
  #
356
307
  def list_tables instance_id, view: nil
357
- execute do
358
- tables.list_tables instance_path(instance_id), view: view
359
- end
308
+ tables.list_tables parent: instance_path(instance_id), view: view
360
309
  end
361
310
 
362
311
  ##
@@ -366,15 +315,13 @@ module Google
366
315
  # Unique ID of the instance the table is in.
367
316
  # @param table_id [String]
368
317
  # Unique ID of the requested table.
369
- # @param view [Google::Bigtable::Admin::V2::Table::View]
318
+ # @param view [Google::Cloud::Bigtable::Admin::V2::Table::View]
370
319
  # View to be applied to the returned table's fields.
371
320
  # Defaults to +SCHEMA_VIEW+ if unspecified.
372
- # @return [Google::Bigtable::Admin::V2::Table]
321
+ # @return [Google::Cloud::Bigtable::Admin::V2::Table]
373
322
  #
374
323
  def get_table instance_id, table_id, view: nil
375
- execute do
376
- tables.get_table table_path(instance_id, table_id), view: view
377
- end
324
+ tables.get_table name: table_path(instance_id, table_id), view: view
378
325
  end
379
326
 
380
327
  ##
@@ -386,9 +333,7 @@ module Google
386
333
  # Unique ID of the table to be deleted.
387
334
  #
388
335
  def delete_table instance_id, table_id
389
- execute do
390
- tables.delete_table table_path(instance_id, table_id)
391
- end
336
+ tables.delete_table name: table_path(instance_id, table_id)
392
337
  end
393
338
 
394
339
  ##
@@ -401,19 +346,18 @@ module Google
401
346
  # Unique ID of the instance the table is in.
402
347
  # @param table_id [String]
403
348
  # Unique ID of the table whose families should be modified.
404
- # @param modifications [Array<Google::Bigtable::Admin::V2::ModifyColumnFamiliesRequest::Modification | Hash>]
349
+ # @param modifications
350
+ # [Array<Google::Cloud::Bigtable::Admin::V2::ModifyColumnFamiliesRequest::Modification | Hash>]
405
351
  # Modifications to be atomically applied to the specified table's families.
406
352
  # Entries are applied in order, meaning that earlier modifications can be
407
353
  # masked by later ones (in the case of repeated updates to the same family,
408
354
  # for example).
409
355
  # Alternatively, provide a hash in the form of
410
- # `Google::Bigtable::Admin::V2::ModifyColumnFamiliesRequest::Modification`.
411
- # @return [Google::Bigtable::Admin::V2::Table]
356
+ # `Google::Cloud::Bigtable::Admin::V2::ModifyColumnFamiliesRequest::Modification`.
357
+ # @return [Google::Cloud::Bigtable::Admin::V2::Table]
412
358
  #
413
359
  def modify_column_families instance_id, table_id, modifications
414
- execute do
415
- tables.modify_column_families table_path(instance_id, table_id), modifications
416
- end
360
+ tables.modify_column_families name: table_path(instance_id, table_id), modifications: modifications
417
361
  end
418
362
 
419
363
  ##
@@ -426,12 +370,10 @@ module Google
426
370
  # Unique ID of the instance the table is in.
427
371
  # @param table_id [String]
428
372
  # Unique ID of the table the consistency token is for.
429
- # @return [Google::Bigtable::Admin::V2::GenerateConsistencyTokenResponse]
373
+ # @return [Google::Cloud::Bigtable::Admin::V2::GenerateConsistencyTokenResponse]
430
374
  #
431
375
  def generate_consistency_token instance_id, table_id
432
- execute do
433
- tables.generate_consistency_token table_path(instance_id, table_id)
434
- end
376
+ tables.generate_consistency_token name: table_path(instance_id, table_id)
435
377
  end
436
378
 
437
379
  ##
@@ -445,12 +387,10 @@ module Google
445
387
  # Unique ID of the table to check for replication consistency.
446
388
  # @param token [String] Consistency token
447
389
  # The token created for the table using GenerateConsistencyToken.
448
- # @return [Google::Bigtable::Admin::V2::CheckConsistencyResponse]
390
+ # @return [Google::Cloud::Bigtable::Admin::V2::CheckConsistencyResponse]
449
391
  #
450
392
  def check_consistency instance_id, table_id, token
451
- execute do
452
- tables.check_consistency table_path(instance_id, table_id), token
453
- end
393
+ tables.check_consistency name: table_path(instance_id, table_id), consistency_token: token
454
394
  end
455
395
 
456
396
  ##
@@ -467,8 +407,7 @@ module Google
467
407
  # Prefix cannot be zero length.
468
408
  # @param delete_all_data_from_table [true, false]
469
409
  # If true, delete all rows in the table. Setting this to false is a no-op.
470
- # @param timeout [Integer]
471
- # Sets the API call timeout if deadline exceeds exception.
410
+ # @param timeout [Integer] Seconds. Sets the API call timeout if deadline exceeds exception.
472
411
  #
473
412
  def drop_row_range instance_id, table_id, row_key_prefix: nil, delete_all_data_from_table: nil, timeout: nil
474
413
  call_options = nil
@@ -476,21 +415,18 @@ module Google
476
415
  # Pass a timeout with a larger value if the drop operation throws
477
416
  # an error for timeout time.
478
417
  if timeout
479
- retry_options = Google::Gax::RetryOptions.new(
480
- [],
481
- Google::Gax::BackoffSettings.new(0, 0, 0, timeout * 1000, 0, 0, 0)
482
- )
483
- call_options = Google::Gax::CallOptions.new retry_options: retry_options
418
+ retry_policy = Gapic::CallOptions::RetryPolicy.new max_delay: timeout * 1000
419
+ call_options = Gapic::CallOptions.new retry_policy: retry_policy
484
420
  end
485
421
 
486
- execute do
487
- tables.drop_row_range(
488
- table_path(instance_id, table_id),
422
+ tables.drop_row_range(
423
+ {
424
+ name: table_path(instance_id, table_id),
489
425
  row_key_prefix: row_key_prefix,
490
- delete_all_data_from_table: delete_all_data_from_table,
491
- options: call_options
492
- )
493
- end
426
+ delete_all_data_from_table: delete_all_data_from_table
427
+ },
428
+ call_options
429
+ )
494
430
  end
495
431
 
496
432
  ##
@@ -501,22 +437,18 @@ module Google
501
437
  # @param app_profile_id [String]
502
438
  # The permanent identifier for the new app profile within its
503
439
  # instance.
504
- # @param app_profile [Google::Bigtable::Admin::V2::AppProfile | Hash]
440
+ # @param app_profile [Google::Cloud::Bigtable::Admin::V2::AppProfile | Hash]
505
441
  # The app profile to be created.
506
- # Alternatively, provide a hash in the form of `Google::Bigtable::Admin::V2::AppProfile`.
442
+ # Alternatively, provide a hash in the form of `Google::Cloud::Bigtable::Admin::V2::AppProfile`.
507
443
  # @param ignore_warnings [Boolean]
508
444
  # If true, ignore safety checks when creating the app profile.
509
- # @return [Google::Bigtable::Admin::V2::AppProfile]
445
+ # @return [Google::Cloud::Bigtable::Admin::V2::AppProfile]
510
446
  #
511
447
  def create_app_profile instance_id, app_profile_id, app_profile, ignore_warnings: nil
512
- execute do
513
- instances.create_app_profile(
514
- instance_path(instance_id),
515
- app_profile_id,
516
- app_profile,
517
- ignore_warnings: ignore_warnings
518
- )
519
- end
448
+ instances.create_app_profile parent: instance_path(instance_id),
449
+ app_profile_id: app_profile_id,
450
+ app_profile: app_profile,
451
+ ignore_warnings: ignore_warnings
520
452
  end
521
453
 
522
454
  ##
@@ -526,12 +458,10 @@ module Google
526
458
  # Unique ID of the instance.
527
459
  # @param app_profile_id [String]
528
460
  # Unique ID of the requested app profile.
529
- # @return [Google::Bigtable::Admin::V2::AppProfile]
461
+ # @return [Google::Cloud::Bigtable::Admin::V2::AppProfile]
530
462
  #
531
463
  def get_app_profile instance_id, app_profile_id
532
- execute do
533
- instances.get_app_profile app_profile_path(instance_id, app_profile_id)
534
- end
464
+ instances.get_app_profile name: app_profile_path(instance_id, app_profile_id)
535
465
  end
536
466
 
537
467
  ##
@@ -539,25 +469,23 @@ module Google
539
469
  #
540
470
  # @param instance_id [String]
541
471
  # Unique ID of the instance
542
- # @return [Google::Gax::PagedEnumerable<Google::Bigtable::Admin::V2::AppProfile>]
543
- # An enumerable of Google::Bigtable::Admin::V2::AppProfile instances.
544
- # See Google::Gax::PagedEnumerable documentation for other
472
+ # @return [Gapic::PagedEnumerable<Google::Cloud::Bigtable::Admin::V2::AppProfile>]
473
+ # An enumerable of Google::Cloud::Bigtable::Admin::V2::AppProfile instances.
474
+ # See Gapic::PagedEnumerable documentation for other
545
475
  # operations such as per-page iteration or access to the response
546
476
  # object.
547
477
  #
548
478
  def list_app_profiles instance_id
549
- execute do
550
- instances.list_app_profiles instance_path(instance_id)
551
- end
479
+ instances.list_app_profiles parent: instance_path(instance_id)
552
480
  end
553
481
 
554
482
  ##
555
483
  # Updates an app profile within an instance.
556
484
  #
557
- # @param app_profile [Google::Bigtable::Admin::V2::AppProfile | Hash]
485
+ # @param app_profile [Google::Cloud::Bigtable::Admin::V2::AppProfile | Hash]
558
486
  # The app profile that will (partially) replace the current value.
559
487
  # Alternatively, provide a hash in the form of
560
- # `Google::Bigtable::Admin::V2::AppProfile`.
488
+ # `Google::Cloud::Bigtable::Admin::V2::AppProfile`.
561
489
  # @param update_mask [Google::Protobuf::FieldMask | Hash]
562
490
  # The subset of app profile fields that should be replaced.
563
491
  # If unset, all fields will be replaced.
@@ -567,9 +495,9 @@ module Google
567
495
  # @return [Google::Longrunning::Operation]
568
496
  #
569
497
  def update_app_profile app_profile, update_mask, ignore_warnings: nil
570
- execute do
571
- instances.update_app_profile app_profile, update_mask, ignore_warnings: ignore_warnings
572
- end
498
+ instances.update_app_profile app_profile: app_profile,
499
+ update_mask: update_mask,
500
+ ignore_warnings: ignore_warnings
573
501
  end
574
502
 
575
503
  ##
@@ -583,9 +511,49 @@ module Google
583
511
  # If true, ignore safety checks when deleting the app profile.
584
512
  #
585
513
  def delete_app_profile instance_id, app_profile_id, ignore_warnings: nil
586
- execute do
587
- instances.delete_app_profile app_profile_path(instance_id, app_profile_id), ignore_warnings
588
- end
514
+ instances.delete_app_profile name: app_profile_path(instance_id, app_profile_id),
515
+ ignore_warnings: ignore_warnings
516
+ end
517
+
518
+ ##
519
+ # Gets the access control policy for an backup resource. Returns an empty
520
+ # policy if an backup exists but does not have a policy set.
521
+ #
522
+ # @return [Google::Iam::V1::Policy]
523
+ #
524
+ def get_backup_policy instance_id, cluster_id, backup_id
525
+ tables.get_iam_policy resource: backup_path(instance_id, cluster_id, backup_id)
526
+ end
527
+
528
+ ##
529
+ # Sets the access control policy on an backup resource. Replaces any
530
+ # existing policy.
531
+ #
532
+ # @param policy [Google::Iam::V1::Policy | Hash]
533
+ # REQUIRED: The complete policy to be applied to the +resource+. The size of
534
+ # the policy is limited to a few 10s of KB. An empty policy is valid
535
+ # for Cloud Bigtable, but certain Cloud Platform services (such as Projects)
536
+ # might reject an empty policy.
537
+ # Alternatively, provide a hash similar to `Google::Iam::V1::Policy`.
538
+ # @return [Google::Iam::V1::Policy]
539
+ #
540
+ def set_backup_policy instance_id, cluster_id, backup_id, policy
541
+ tables.set_iam_policy resource: backup_path(instance_id, cluster_id, backup_id), policy: policy
542
+ end
543
+
544
+ ##
545
+ # Returns permissions that the caller has for the specified backup resource.
546
+ #
547
+ # @param permissions [Array<String>]
548
+ # The set of permissions to check for the +resource+. Permissions with
549
+ # wildcards (such as '*' or 'storage.*') are not allowed. For more
550
+ # information see
551
+ # [IAM Overview](https://cloud.google.com/iam/docs/overview#permissions).
552
+ # @return [Google::Iam::V1::TestIamPermissionsResponse]
553
+ #
554
+ def test_backup_permissions instance_id, cluster_id, backup_id, permissions
555
+ tables.test_iam_permissions resource: backup_path(instance_id, cluster_id, backup_id),
556
+ permissions: permissions
589
557
  end
590
558
 
591
559
  ##
@@ -597,9 +565,7 @@ module Google
597
565
  # @return [Google::Iam::V1::Policy]
598
566
  #
599
567
  def get_instance_policy instance_id
600
- execute do
601
- instances.get_iam_policy instance_path(instance_id)
602
- end
568
+ instances.get_iam_policy resource: instance_path(instance_id)
603
569
  end
604
570
 
605
571
  ##
@@ -617,9 +583,7 @@ module Google
617
583
  # @return [Google::Iam::V1::Policy]
618
584
  #
619
585
  def set_instance_policy instance_id, policy
620
- execute do
621
- instances.set_iam_policy instance_path(instance_id), policy
622
- end
586
+ instances.set_iam_policy resource: instance_path(instance_id), policy: policy
623
587
  end
624
588
 
625
589
  ##
@@ -635,9 +599,7 @@ module Google
635
599
  # @return [Google::Iam::V1::TestIamPermissionsResponse]
636
600
  #
637
601
  def test_instance_permissions instance_id, permissions
638
- execute do
639
- instances.test_iam_permissions instance_path(instance_id), permissions
640
- end
602
+ instances.test_iam_permissions resource: instance_path(instance_id), permissions: permissions
641
603
  end
642
604
 
643
605
  ##
@@ -649,9 +611,7 @@ module Google
649
611
  # @return [Google::Iam::V1::Policy]
650
612
  #
651
613
  def get_table_policy instance_id, table_id
652
- execute do
653
- tables.get_iam_policy table_path(instance_id, table_id)
654
- end
614
+ tables.get_iam_policy resource: table_path(instance_id, table_id)
655
615
  end
656
616
 
657
617
  ##
@@ -669,9 +629,7 @@ module Google
669
629
  # @return [Google::Iam::V1::Policy]
670
630
  #
671
631
  def set_table_policy instance_id, table_id, policy
672
- execute do
673
- tables.set_iam_policy table_path(instance_id, table_id), policy
674
- end
632
+ tables.set_iam_policy resource: table_path(instance_id, table_id), policy: policy
675
633
  end
676
634
 
677
635
  ##
@@ -687,14 +645,11 @@ module Google
687
645
  # @return [Google::Iam::V1::TestIamPermissionsResponse]
688
646
  #
689
647
  def test_table_permissions instance_id, table_id, permissions
690
- execute do
691
- tables.test_iam_permissions table_path(instance_id, table_id), permissions
692
- end
648
+ tables.test_iam_permissions resource: table_path(instance_id, table_id), permissions: permissions
693
649
  end
694
650
 
695
651
  def read_rows instance_id, table_id, app_profile_id: nil, rows: nil, filter: nil, rows_limit: nil
696
- # execute is not used because error handling is in ReadOperations#read_rows
697
- client.read_rows table_path(instance_id, table_id),
652
+ client.read_rows table_name: table_path(instance_id, table_id),
698
653
  rows: rows,
699
654
  filter: filter,
700
655
  rows_limit: rows_limit,
@@ -702,84 +657,95 @@ module Google
702
657
  end
703
658
 
704
659
  def sample_row_keys table_name, app_profile_id: nil
705
- execute do
706
- client.sample_row_keys table_name, app_profile_id: app_profile_id
707
- end
660
+ client.sample_row_keys table_name: table_name, app_profile_id: app_profile_id
708
661
  end
709
662
 
710
663
  def mutate_row table_name, row_key, mutations, app_profile_id: nil
711
- execute do
712
- client.mutate_row table_name, row_key, mutations, app_profile_id: app_profile_id
713
- end
664
+ client.mutate_row(
665
+ {
666
+ table_name: table_name,
667
+ app_profile_id: app_profile_id,
668
+ row_key: row_key,
669
+ mutations: mutations
670
+ }.delete_if { |_, v| v.nil? }
671
+ )
714
672
  end
715
673
 
716
674
  def mutate_rows table_name, entries, app_profile_id: nil
717
- execute do
718
- client.mutate_rows table_name, entries, app_profile_id: app_profile_id
719
- end
675
+ client.mutate_rows(
676
+ {
677
+ table_name: table_name,
678
+ app_profile_id: app_profile_id,
679
+ entries: entries
680
+ }.delete_if { |_, v| v.nil? }
681
+ )
720
682
  end
721
683
 
722
- def check_and_mutate_row table_name, row_key, app_profile_id: nil, predicate_filter: nil, true_mutations: nil,
684
+ def check_and_mutate_row table_name,
685
+ row_key,
686
+ app_profile_id: nil,
687
+ predicate_filter: nil,
688
+ true_mutations: nil,
723
689
  false_mutations: nil
724
- execute do
725
- client.check_and_mutate_row table_name, row_key, app_profile_id: app_profile_id,
726
- predicate_filter: predicate_filter, true_mutations: true_mutations,
727
- false_mutations: false_mutations
728
- end
690
+ client.check_and_mutate_row(
691
+ {
692
+ table_name: table_name,
693
+ app_profile_id: app_profile_id,
694
+ row_key: row_key,
695
+ predicate_filter: predicate_filter,
696
+ true_mutations: true_mutations,
697
+ false_mutations: false_mutations
698
+ }.delete_if { |_, v| v.nil? }
699
+ )
729
700
  end
730
701
 
731
702
  def read_modify_write_row table_name, row_key, rules, app_profile_id: nil
732
- execute do
733
- client.read_modify_write_row table_name, row_key, rules, app_profile_id: app_profile_id
734
- end
703
+ client.read_modify_write_row(
704
+ {
705
+ table_name: table_name,
706
+ app_profile_id: app_profile_id,
707
+ row_key: row_key,
708
+ rules: rules
709
+ }.delete_if { |_, v| v.nil? }
710
+ )
735
711
  end
736
712
 
737
713
  ##
738
714
  # Starts creating a new backup. The underlying Google::Longrunning::Operation tracks creation of the backup.
739
715
  #
740
- # @return [Google::Gax::Operation]
716
+ # @return [Gapic::Operation]
741
717
  #
742
718
  def create_backup instance_id:, cluster_id:, backup_id:, source_table_id:, expire_time:
743
- backup = Google::Bigtable::Admin::V2::Backup.new source_table: table_path(instance_id, source_table_id),
744
- expire_time: expire_time
745
- execute do
746
- tables.create_backup cluster_path(instance_id, cluster_id), backup_id, backup
747
- end
719
+ backup = Google::Cloud::Bigtable::Admin::V2::Backup.new \
720
+ source_table: table_path(instance_id, source_table_id), expire_time: expire_time
721
+ tables.create_backup parent: cluster_path(instance_id, cluster_id), backup_id: backup_id, backup: backup
748
722
  end
749
723
 
750
724
  ##
751
- # @return [Google::Bigtable::Admin::V2::Backup]
725
+ # @return [Google::Cloud::Bigtable::Admin::V2::Backup]
752
726
  #
753
727
  def get_backup instance_id, cluster_id, backup_id
754
- execute do
755
- tables.get_backup backup_path(instance_id, cluster_id, backup_id)
756
- end
728
+ tables.get_backup name: backup_path(instance_id, cluster_id, backup_id)
757
729
  end
758
730
 
759
731
  ##
760
- # @return [Google::Gax::PagedEnumerable<Google::Bigtable::Admin::V2::Backup>]
732
+ # @return [Gapic::PagedEnumerable<Google::Cloud::Bigtable::Admin::V2::Backup>]
761
733
  #
762
734
  def list_backups instance_id, cluster_id
763
- execute do
764
- tables.list_backups cluster_path(instance_id, cluster_id)
765
- end
735
+ tables.list_backups parent: cluster_path(instance_id, cluster_id)
766
736
  end
767
737
 
768
738
  ##
769
- # @param backup [Google::Bigtable::Admin::V2::Backup | Hash]
739
+ # @param backup [Google::Cloud::Bigtable::Admin::V2::Backup | Hash]
770
740
  # @param fields [Array(String|Symbol)] the paths of fields to be updated
771
741
  #
772
742
  def update_backup backup, fields
773
743
  mask = Google::Protobuf::FieldMask.new paths: fields.map(&:to_s)
774
- execute do
775
- tables.update_backup backup, mask
776
- end
744
+ tables.update_backup backup: backup, update_mask: mask
777
745
  end
778
746
 
779
747
  def delete_backup instance_id, cluster_id, backup_id
780
- execute do
781
- tables.delete_backup backup_path(instance_id, cluster_id, backup_id)
782
- end
748
+ tables.delete_backup name: backup_path(instance_id, cluster_id, backup_id)
783
749
  end
784
750
 
785
751
  ##
@@ -790,30 +756,15 @@ module Google
790
756
  # @param cluster_id [String] The cluster ID for the source backup.
791
757
  # @param backup_id [String] The backup ID for the source backup.
792
758
  #
793
- # @return [Google::Gax::Operation] The {Google::Longrunning::Operation#metadata metadata} field type is
794
- # {Google::Bigtable::Admin::RestoreTableMetadata RestoreTableMetadata}. The
795
- # {Google::Longrunning::Operation#response response} type is {Google::Bigtable::Admin::V2::Table Table}, if
796
- # successful.
759
+ # @return [Gapic::Operation] The {Google::Longrunning::Operation#metadata metadata} field type is
760
+ # {Google::Cloud::Bigtable::Admin::RestoreTableMetadata RestoreTableMetadata}. The
761
+ # {Google::Longrunning::Operation#response response} type is
762
+ # {Google::Cloud::Bigtable::Admin::V2::Table Table}, if successful.
797
763
  #
798
764
  def restore_table table_id, instance_id, cluster_id, backup_id
799
- execute do
800
- tables.restore_table instance_path(instance_id),
801
- table_id: table_id,
802
- backup: backup_path(instance_id, cluster_id, backup_id)
803
- end
804
- end
805
-
806
- ##
807
- # Executes the API call and wrap errors to {Google::Cloud::Error}.
808
- #
809
- # @raise [Google::Cloud::Error]
810
- #
811
- def execute
812
- yield
813
- rescue Google::Gax::GaxError => e
814
- raise Google::Cloud::Error.from_error(e.cause)
815
- rescue GRPC::BadStatus => e
816
- raise Google::Cloud::Error.from_error(e)
765
+ tables.restore_table parent: instance_path(instance_id),
766
+ table_id: table_id,
767
+ backup: backup_path(instance_id, cluster_id, backup_id)
817
768
  end
818
769
 
819
770
  ##
@@ -824,7 +775,7 @@ module Google
824
775
  # +projects/<project>+
825
776
  #
826
777
  def project_path
827
- Admin::V2::BigtableInstanceAdminClient.project_path project_id
778
+ Admin::V2::BigtableInstanceAdmin::Paths.project_path project: project_id
828
779
  end
829
780
 
830
781
  ##
@@ -836,7 +787,7 @@ module Google
836
787
  # +projects/<project>/instances/[a-z][a-z0-9\\-]+[a-z0-9]+.
837
788
  #
838
789
  def instance_path instance_id
839
- Admin::V2::BigtableInstanceAdminClient.instance_path project_id, instance_id
790
+ Admin::V2::BigtableInstanceAdmin::Paths.instance_path project: project_id, instance: instance_id
840
791
  end
841
792
 
842
793
  ##
@@ -849,7 +800,9 @@ module Google
849
800
  # +projects/<project>/instances/<instance>/clusters/<cluster>+.
850
801
  #
851
802
  def cluster_path instance_id, cluster_id
852
- Admin::V2::BigtableInstanceAdminClient.cluster_path project_id, instance_id, cluster_id
803
+ Admin::V2::BigtableInstanceAdmin::Paths.cluster_path project: project_id,
804
+ instance: instance_id,
805
+ cluster: cluster_id
853
806
  end
854
807
 
855
808
  ##
@@ -862,7 +815,7 @@ module Google
862
815
  # +projects/<project_id>/locations/<location>+.
863
816
  #
864
817
  def location_path location
865
- Admin::V2::BigtableInstanceAdminClient.location_path project_id, location
818
+ Admin::V2::BigtableInstanceAdmin::Paths.location_path project: project_id, location: location
866
819
  end
867
820
 
868
821
  ##
@@ -874,7 +827,7 @@ module Google
874
827
  # +projects/<project>/instances/<instance>/tables/<table>+
875
828
  #
876
829
  def table_path instance_id, table_id
877
- Admin::V2::BigtableTableAdminClient.table_path project_id, instance_id, table_id
830
+ Admin::V2::BigtableTableAdmin::Paths.table_path project: project_id, instance: instance_id, table: table_id
878
831
  end
879
832
 
880
833
  ##
@@ -887,7 +840,9 @@ module Google
887
840
  # +projects/<project>/instances/<instance>/appProfiles/<app_profile>+
888
841
  #
889
842
  def app_profile_path instance_id, app_profile_id
890
- Admin::V2::BigtableInstanceAdminClient.app_profile_path project_id, instance_id, app_profile_id
843
+ Admin::V2::BigtableInstanceAdmin::Paths.app_profile_path project: project_id,
844
+ instance: instance_id,
845
+ app_profile: app_profile_id
891
846
  end
892
847
 
893
848
  ##
@@ -897,7 +852,10 @@ module Google
897
852
  # `projects/<project>/instances/<instance>/clusters/<cluster>/backups/<backup>`
898
853
  #
899
854
  def backup_path instance_id, cluster_id, backup_id
900
- Admin::V2::BigtableTableAdminClient.backup_path project_id, instance_id, cluster_id, backup_id
855
+ Admin::V2::BigtableTableAdmin::Paths.backup_path project: project_id,
856
+ instance: instance_id,
857
+ cluster: cluster_id,
858
+ backup: backup_id
901
859
  end
902
860
 
903
861
  ##