google-cloud-bigtable 2.2.0 → 2.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +42 -0
  3. data/CONTRIBUTING.md +4 -5
  4. data/LOGGING.md +1 -1
  5. data/OVERVIEW.md +5 -5
  6. data/lib/google/cloud/bigtable/app_profile/list.rb +2 -2
  7. data/lib/google/cloud/bigtable/backup.rb +22 -1
  8. data/lib/google/cloud/bigtable/backup/list.rb +2 -2
  9. data/lib/google/cloud/bigtable/chunk_processor.rb +4 -3
  10. data/lib/google/cloud/bigtable/cluster.rb +22 -2
  11. data/lib/google/cloud/bigtable/cluster/list.rb +2 -2
  12. data/lib/google/cloud/bigtable/column_family.rb +4 -0
  13. data/lib/google/cloud/bigtable/column_family_map.rb +2 -0
  14. data/lib/google/cloud/bigtable/convert.rb +12 -0
  15. data/lib/google/cloud/bigtable/encryption_info.rb +118 -0
  16. data/lib/google/cloud/bigtable/gc_rule.rb +2 -0
  17. data/lib/google/cloud/bigtable/instance.rb +3 -2
  18. data/lib/google/cloud/bigtable/instance/cluster_map.rb +61 -21
  19. data/lib/google/cloud/bigtable/instance/list.rb +2 -2
  20. data/lib/google/cloud/bigtable/mutation_entry.rb +12 -9
  21. data/lib/google/cloud/bigtable/mutation_operations.rb +6 -5
  22. data/lib/google/cloud/bigtable/policy.rb +2 -1
  23. data/lib/google/cloud/bigtable/project.rb +4 -3
  24. data/lib/google/cloud/bigtable/routing_policy.rb +3 -1
  25. data/lib/google/cloud/bigtable/row.rb +5 -1
  26. data/lib/google/cloud/bigtable/row_filter/simple_filter.rb +6 -1
  27. data/lib/google/cloud/bigtable/rows_reader.rb +6 -6
  28. data/lib/google/cloud/bigtable/status.rb +4 -1
  29. data/lib/google/cloud/bigtable/table.rb +62 -19
  30. data/lib/google/cloud/bigtable/table/cluster_state.rb +43 -9
  31. data/lib/google/cloud/bigtable/table/list.rb +2 -2
  32. data/lib/google/cloud/bigtable/table/restore_job.rb +1 -1
  33. data/lib/google/cloud/bigtable/value_range.rb +24 -6
  34. data/lib/google/cloud/bigtable/version.rb +1 -1
  35. metadata +7 -6
@@ -15,6 +15,8 @@
15
15
  # limitations under the License.
16
16
 
17
17
 
18
+ require "google/cloud/bigtable/encryption_info"
19
+
18
20
  module Google
19
21
  module Cloud
20
22
  module Bigtable
@@ -23,6 +25,20 @@ module Google
23
25
  # Table::ClusterState is the state of a table's data in a particular cluster.
24
26
  #
25
27
  # @attr [String] cluster_name The name of the cluster.
28
+ #
29
+ # @example Retrieve a table with cluster states.
30
+ # require "google/cloud/bigtable"
31
+ #
32
+ # bigtable = Google::Cloud::Bigtable.new
33
+ #
34
+ # table = bigtable.table("my-instance", "my-table", view: :FULL, perform_lookup: true)
35
+ #
36
+ # table.cluster_states.each do |cs|
37
+ # puts cs.cluster_name
38
+ # puts cs.replication_state
39
+ # puts cs.encryption_infos.first.encryption_type
40
+ # end
41
+ #
26
42
  class ClusterState
27
43
  attr_reader :cluster_name
28
44
 
@@ -36,7 +52,7 @@ module Google
36
52
 
37
53
  ##
38
54
  # The state of replication for the table in this cluster.
39
- # Valid values are:
55
+ # Valid values include:
40
56
  # * `:INITIALIZING` - The cluster was recently created.
41
57
  # * `:PLANNED_MAINTENANCE` - The table is temporarily unable to serve.
42
58
  # * `:UNPLANNED_MAINTENANCE` - The table is temporarily unable to serve.
@@ -45,6 +61,10 @@ module Google
45
61
  # after a restore, and is being optimized for performance. When
46
62
  # optimizations are complete, the table will transition to `READY`
47
63
  # state.
64
+ # * `:STATE_NOT_KNOWN` - If replication state is not present in the object
65
+ # because the table view is not `REPLICATION_VIEW` or `FULL`.
66
+ # * `:UNKNOWN` - If it could not be determined whether or not the table
67
+ # has data in a particular cluster (for example, if its zone is unavailable.)
48
68
  #
49
69
  # @return [Symbol] The state of replication.
50
70
  #
@@ -57,7 +77,8 @@ module Google
57
77
  # over pre-existing data from other clusters before it can begin
58
78
  # receiving live replication updates and serving.
59
79
  #
60
- # @return [Boolean] `true` if the table in this cluster is initializing.
80
+ # @return [Boolean] `true` if the value of {#replication_state} is `INITIALIZING`,
81
+ # `false` otherwise.
61
82
  #
62
83
  def initializing?
63
84
  replication_state == :INITIALIZING
@@ -67,8 +88,8 @@ module Google
67
88
  # The table is temporarily unable to serve
68
89
  # requests from this cluster due to planned internal maintenance.
69
90
  #
70
- # @return [Boolean] `true` if the table in this cluster is in planned
71
- # maintenance.
91
+ # @return [Boolean] `true` if the value of {#replication_state} is `PLANNED_MAINTENANCE`,
92
+ # `false` otherwise.
72
93
  #
73
94
  def planned_maintenance?
74
95
  replication_state == :PLANNED_MAINTENANCE
@@ -78,8 +99,8 @@ module Google
78
99
  # The table is temporarily unable to serve requests from this
79
100
  # cluster due to unplanned or emergency maintenance.
80
101
  #
81
- # @return [Boolean] `true` if the table in this cluster is in unplanned
82
- # maintenance.
102
+ # @return [Boolean] `true` if the value of {#replication_state} is `UNPLANNED_MAINTENANCE`,
103
+ # `false` otherwise.
83
104
  #
84
105
  def unplanned_maintenance?
85
106
  replication_state == :UNPLANNED_MAINTENANCE
@@ -90,7 +111,8 @@ module Google
90
111
  # Depending on replication delay, reads may not immediately
91
112
  # reflect the state of the table in other clusters.
92
113
  #
93
- # @return [Boolean] `true` if the table in this cluster is ready.
114
+ # @return [Boolean] `true` if the value of {#replication_state} is `READY`,
115
+ # `false` otherwise.
94
116
  #
95
117
  def ready?
96
118
  replication_state == :READY
@@ -102,13 +124,25 @@ module Google
102
124
  # optimizations are complete, the table will transition to `READY`
103
125
  # state.
104
126
  #
105
- # @return [Boolean] `true` if the table in this cluster is being
106
- # optimized.
127
+ # @return [Boolean] `true` if the value of {#replication_state} is `READY_OPTIMIZING`,
128
+ # `false` otherwise.
107
129
  #
108
130
  def ready_optimizing?
109
131
  replication_state == :READY_OPTIMIZING
110
132
  end
111
133
 
134
+ ##
135
+ # The encryption info value objects for the table in this cluster. The encryption info
136
+ # is only present when the table view is `ENCRYPTION_VIEW` or `FULL`. See also
137
+ # {Instance::ClusterMap#add}.
138
+ #
139
+ # @return [Array<Google::Cloud::Bigtable::EncryptionInfo>] The array of encryption info
140
+ # value objects, or an empty array if none are present.
141
+ #
142
+ def encryption_infos
143
+ @grpc.encryption_info.map { |ei_grpc| Google::Cloud::Bigtable::EncryptionInfo.from_grpc ei_grpc }
144
+ end
145
+
112
146
  # @private
113
147
  # New Table::ClusterState from a Google::Cloud::Bigtable::Admin::V2::Table::ClusterState object.
114
148
  # @param grpc [Google::Cloud::Bigtable::Admin::V2::Table::ClusterState]
@@ -114,12 +114,12 @@ module Google
114
114
  # puts table.table_id
115
115
  # end
116
116
  #
117
- def all
117
+ def all &block
118
118
  return enum_for :all unless block_given?
119
119
 
120
120
  results = self
121
121
  loop do
122
- results.each { |r| yield r }
122
+ results.each(&block)
123
123
  break unless next?
124
124
  grpc.next_page
125
125
  results = self.class.from_grpc grpc, service
@@ -108,7 +108,7 @@ module Google
108
108
  # end
109
109
  #
110
110
  def table
111
- Table.from_grpc results, service if results
111
+ Table.from_grpc results, service, view: :NAME_ONLY if results
112
112
  end
113
113
  end
114
114
  end
@@ -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
@@ -65,7 +67,9 @@ module Google
65
67
  ##
66
68
  # Sets the row range with the lower bound.
67
69
  #
68
- # @param value [String] The value. Required.
70
+ # @param value [String, Integer] The value. Required. If the argument
71
+ # is an Integer, it will be encoded as a 64-bit signed big-endian
72
+ # integer.
69
73
  # @param inclusive [Boolean] Whether the value is an inclusive or
70
74
  # exclusive lower bound. Default is `true`, an inclusive lower bound.
71
75
  # @return [Google::Cloud::Bigtable::ValueRange]
@@ -87,6 +91,8 @@ module Google
87
91
  # range = table.new_value_range.from("value-001", inclusive: false)
88
92
  #
89
93
  def from value, inclusive: true
94
+ # If value is integer, covert it to a 64-bit signed big-endian integer.
95
+ value = Convert.integer_to_signed_be_64 value
90
96
  if inclusive
91
97
  @grpc.start_value_closed = value
92
98
  else
@@ -98,7 +104,9 @@ module Google
98
104
  ##
99
105
  # Sets the value range with upper bound.
100
106
  #
101
- # @param value [String] value. Required
107
+ # @param value [String, Integer] value. Required. If the argument
108
+ # is an Integer, it will be encoded as a 64-bit signed big-endian
109
+ # integer.
102
110
  # @param inclusive [Boolean] Whether the value is an inclusive or
103
111
  # exclusive lower bound. Default is `false`, an exclusive lower bound.
104
112
  # @return [Google::Cloud::Bigtable::ValueRange]
@@ -120,6 +128,8 @@ module Google
120
128
  # range = table.new_value_range.to("value-010")
121
129
  #
122
130
  def to value, inclusive: false
131
+ # If value is integer, covert it to a 64-bit signed big-endian integer.
132
+ value = Convert.integer_to_signed_be_64 value
123
133
  if inclusive
124
134
  @grpc.end_value_closed = value
125
135
  else
@@ -131,8 +141,12 @@ module Google
131
141
  ##
132
142
  # Sets the value range with inclusive lower and upper bounds.
133
143
  #
134
- # @param from_value [String] Inclusive from value. Required
135
- # @param to_value [String] Inclusive to value. Required
144
+ # @param from_value [String, Integer] Inclusive from value. Required.
145
+ # If the argument is an Integer, it will be encoded as a 64-bit
146
+ # signed big-endian integer.
147
+ # @param to_value [String, Integer] Inclusive to value. Required.
148
+ # If the argument is an Integer, it will be encoded as a 64-bit
149
+ # signed big-endian integer.
136
150
  # @return [Google::Cloud::Bigtable::ValueRange]
137
151
  # Range with inclusive from and to values.
138
152
  #
@@ -151,8 +165,12 @@ module Google
151
165
  ##
152
166
  # Set value range with an inclusive lower bound and an exclusive upper bound.
153
167
  #
154
- # @param from_value [String] Inclusive from value
155
- # @param to_value [String] Exclusive to value
168
+ # @param from_value [String, Integer] Inclusive from value. Required.
169
+ # If the argument is an Integer, it will be encoded as a 64-bit
170
+ # signed big-endian integer.
171
+ # @param to_value [String, Integer] Exclusive to value. Required.
172
+ # If the argument is an Integer, it will be encoded as a 64-bit
173
+ # signed big-endian integer.
156
174
  # @return [Google::Cloud::Bigtable::ValueRange]
157
175
  # Range with an inclusive from value and an exclusive to value.
158
176
  #
@@ -16,7 +16,7 @@
16
16
  module Google
17
17
  module Cloud
18
18
  module Bigtable
19
- VERSION = "2.2.0".freeze
19
+ VERSION = "2.5.0".freeze
20
20
  end
21
21
  end
22
22
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: google-cloud-bigtable
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.0
4
+ version: 2.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Google LLC
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-11-11 00:00:00.000000000 Z
11
+ date: 2021-04-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: google-cloud-bigtable-admin-v2
@@ -58,14 +58,14 @@ dependencies:
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: 1.24.0
61
+ version: 1.25.1
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: 1.24.0
68
+ version: 1.25.1
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: minitest
71
71
  requirement: !ruby/object:Gem::Requirement
@@ -197,6 +197,7 @@ files:
197
197
  - lib/google/cloud/bigtable/column_range.rb
198
198
  - lib/google/cloud/bigtable/convert.rb
199
199
  - lib/google/cloud/bigtable/credentials.rb
200
+ - lib/google/cloud/bigtable/encryption_info.rb
200
201
  - lib/google/cloud/bigtable/errors.rb
201
202
  - lib/google/cloud/bigtable/gc_rule.rb
202
203
  - lib/google/cloud/bigtable/instance.rb
@@ -241,14 +242,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
241
242
  requirements:
242
243
  - - ">="
243
244
  - !ruby/object:Gem::Version
244
- version: '2.4'
245
+ version: '2.5'
245
246
  required_rubygems_version: !ruby/object:Gem::Requirement
246
247
  requirements:
247
248
  - - ">="
248
249
  - !ruby/object:Gem::Version
249
250
  version: '0'
250
251
  requirements: []
251
- rubygems_version: 3.1.4
252
+ rubygems_version: 3.2.13
252
253
  signing_key:
253
254
  specification_version: 4
254
255
  summary: API Client library for Cloud Bigtable API