google-cloud-bigtable 2.4.1 → 2.6.2

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 (42) hide show
  1. checksums.yaml +4 -4
  2. data/AUTHENTICATION.md +2 -1
  3. data/CHANGELOG.md +32 -0
  4. data/CONTRIBUTING.md +2 -3
  5. data/OVERVIEW.md +1 -1
  6. data/lib/google/cloud/bigtable/app_profile.rb +20 -21
  7. data/lib/google/cloud/bigtable/app_profile/job.rb +4 -4
  8. data/lib/google/cloud/bigtable/app_profile/list.rb +5 -7
  9. data/lib/google/cloud/bigtable/backup.rb +83 -32
  10. data/lib/google/cloud/bigtable/backup/job.rb +8 -8
  11. data/lib/google/cloud/bigtable/backup/list.rb +9 -11
  12. data/lib/google/cloud/bigtable/cluster.rb +37 -17
  13. data/lib/google/cloud/bigtable/cluster/job.rb +2 -2
  14. data/lib/google/cloud/bigtable/column_family.rb +2 -2
  15. data/lib/google/cloud/bigtable/column_family_map.rb +14 -14
  16. data/lib/google/cloud/bigtable/column_range.rb +7 -7
  17. data/lib/google/cloud/bigtable/encryption_info.rb +118 -0
  18. data/lib/google/cloud/bigtable/gc_rule.rb +20 -20
  19. data/lib/google/cloud/bigtable/instance.rb +40 -40
  20. data/lib/google/cloud/bigtable/instance/cluster_map.rb +61 -21
  21. data/lib/google/cloud/bigtable/instance/job.rb +4 -4
  22. data/lib/google/cloud/bigtable/mutation_entry.rb +21 -21
  23. data/lib/google/cloud/bigtable/mutation_operations.rb +34 -34
  24. data/lib/google/cloud/bigtable/policy.rb +4 -4
  25. data/lib/google/cloud/bigtable/project.rb +15 -15
  26. data/lib/google/cloud/bigtable/read_operations.rb +31 -31
  27. data/lib/google/cloud/bigtable/routing_policy.rb +6 -6
  28. data/lib/google/cloud/bigtable/row_filter.rb +28 -28
  29. data/lib/google/cloud/bigtable/row_filter/chain_filter.rb +30 -29
  30. data/lib/google/cloud/bigtable/row_filter/condition_filter.rb +6 -6
  31. data/lib/google/cloud/bigtable/row_filter/interleave_filter.rb +27 -26
  32. data/lib/google/cloud/bigtable/row_range.rb +18 -18
  33. data/lib/google/cloud/bigtable/sample_row_key.rb +1 -1
  34. data/lib/google/cloud/bigtable/service.rb +6 -3
  35. data/lib/google/cloud/bigtable/status.rb +2 -2
  36. data/lib/google/cloud/bigtable/table.rb +66 -43
  37. data/lib/google/cloud/bigtable/table/cluster_state.rb +43 -9
  38. data/lib/google/cloud/bigtable/table/list.rb +2 -2
  39. data/lib/google/cloud/bigtable/table/restore_job.rb +12 -12
  40. data/lib/google/cloud/bigtable/value_range.rb +18 -18
  41. data/lib/google/cloud/bigtable/version.rb +1 -1
  42. metadata +4 -3
@@ -49,15 +49,15 @@ module Google
49
49
  #
50
50
  # bigtable = Google::Cloud::Bigtable.new
51
51
  #
52
- # table = bigtable.create_table("my-instance", "my-table") do |cfm|
53
- # cfm.add("cf1", gc_rule: Google::Cloud::Bigtable::GcRule.max_versions(5))
54
- # cfm.add("cf2", gc_rule: Google::Cloud::Bigtable::GcRule.max_age(600))
52
+ # table = bigtable.create_table "my-instance", "my-table" do |cfm|
53
+ # cfm.add "cf1", gc_rule: Google::Cloud::Bigtable::GcRule.max_versions(5)
54
+ # cfm.add "cf2", gc_rule: Google::Cloud::Bigtable::GcRule.max_age(600)
55
55
  #
56
56
  # gc_rule = Google::Cloud::Bigtable::GcRule.union(
57
57
  # Google::Cloud::Bigtable::GcRule.max_age(1800),
58
58
  # Google::Cloud::Bigtable::GcRule.max_versions(3)
59
59
  # )
60
- # cfm.add("cf3", gc_rule: gc_rule)
60
+ # cfm.add "cf3", gc_rule: gc_rule
61
61
  # end
62
62
  #
63
63
  # puts table.column_families["cf1"].gc_rule.max_versions
@@ -95,8 +95,8 @@ module Google
95
95
  #
96
96
  # bigtable = Google::Cloud::Bigtable.new
97
97
  #
98
- # table = bigtable.create_table("my-instance", "my-table") do |cfm|
99
- # cfm.add("cf1", gc_rule: Google::Cloud::Bigtable::GcRule.max_versions(5))
98
+ # table = bigtable.create_table "my-instance", "my-table" do |cfm|
99
+ # cfm.add "cf1", gc_rule: Google::Cloud::Bigtable::GcRule.max_versions(5)
100
100
  # end
101
101
  #
102
102
  # puts table.column_families["cf1"].gc_rule.max_versions
@@ -131,8 +131,8 @@ module Google
131
131
  #
132
132
  # bigtable = Google::Cloud::Bigtable.new
133
133
  #
134
- # table = bigtable.create_table("my-instance", "my-table") do |cfm|
135
- # cfm.add("cf1", gc_rule: Google::Cloud::Bigtable::GcRule.max_age(600))
134
+ # table = bigtable.create_table "my-instance", "my-table" do |cfm|
135
+ # cfm.add "cf1", gc_rule: Google::Cloud::Bigtable::GcRule.max_age(600)
136
136
  # end
137
137
  #
138
138
  # puts table.column_families["cf1"].gc_rule.max_age
@@ -162,12 +162,12 @@ module Google
162
162
  #
163
163
  # bigtable = Google::Cloud::Bigtable.new
164
164
  #
165
- # table = bigtable.create_table("my-instance", "my-table") do |cfm|
165
+ # table = bigtable.create_table "my-instance", "my-table" do |cfm|
166
166
  # gc_rule = Google::Cloud::Bigtable::GcRule.intersection(
167
167
  # Google::Cloud::Bigtable::GcRule.max_age(1800),
168
168
  # Google::Cloud::Bigtable::GcRule.max_versions(3)
169
169
  # )
170
- # cfm.add("cf1", gc_rule: gc_rule)
170
+ # cfm.add "cf1", gc_rule: gc_rule
171
171
  # end
172
172
  #
173
173
  # puts table.column_families["cf1"].gc_rule.intersection
@@ -203,12 +203,12 @@ module Google
203
203
  #
204
204
  # bigtable = Google::Cloud::Bigtable.new
205
205
  #
206
- # table = bigtable.create_table("my-instance", "my-table") do |cfm|
206
+ # table = bigtable.create_table "my-instance", "my-table" do |cfm|
207
207
  # gc_rule = Google::Cloud::Bigtable::GcRule.union(
208
208
  # Google::Cloud::Bigtable::GcRule.max_age(1800),
209
209
  # Google::Cloud::Bigtable::GcRule.max_versions(3)
210
210
  # )
211
- # cfm.add("cf1", gc_rule: gc_rule)
211
+ # cfm.add "cf1", gc_rule: gc_rule
212
212
  # end
213
213
  #
214
214
  # puts table.column_families["cf1"].gc_rule.union
@@ -231,8 +231,8 @@ module Google
231
231
  #
232
232
  # bigtable = Google::Cloud::Bigtable.new
233
233
  #
234
- # table = bigtable.create_table("my-instance", "my-table") do |cfm|
235
- # cfm.add("cf1", gc_rule: Google::Cloud::Bigtable::GcRule.max_versions(5))
234
+ # table = bigtable.create_table "my-instance", "my-table" do |cfm|
235
+ # cfm.add "cf1", gc_rule: Google::Cloud::Bigtable::GcRule.max_versions(5)
236
236
  # end
237
237
  #
238
238
  def self.max_versions versions
@@ -252,8 +252,8 @@ module Google
252
252
  #
253
253
  # bigtable = Google::Cloud::Bigtable.new
254
254
  #
255
- # table = bigtable.create_table("my-instance", "my-table") do |cfm|
256
- # cfm.add("cf1", gc_rule: Google::Cloud::Bigtable::GcRule.max_age(600))
255
+ # table = bigtable.create_table "my-instance", "my-table" do |cfm|
256
+ # cfm.add "cf1", gc_rule: Google::Cloud::Bigtable::GcRule.max_age(600)
257
257
  # end
258
258
  #
259
259
  def self.max_age age
@@ -274,12 +274,12 @@ module Google
274
274
  #
275
275
  # bigtable = Google::Cloud::Bigtable.new
276
276
  #
277
- # table = bigtable.create_table("my-instance", "my-table") do |cfm|
277
+ # table = bigtable.create_table "my-instance", "my-table" do |cfm|
278
278
  # gc_rule = Google::Cloud::Bigtable::GcRule.union(
279
279
  # Google::Cloud::Bigtable::GcRule.max_age(1800),
280
280
  # Google::Cloud::Bigtable::GcRule.max_versions(3)
281
281
  # )
282
- # cfm.add("cf1", gc_rule: gc_rule)
282
+ # cfm.add "cf1", gc_rule: gc_rule
283
283
  # end
284
284
  #
285
285
  def self.union *rules
@@ -300,12 +300,12 @@ module Google
300
300
  #
301
301
  # bigtable = Google::Cloud::Bigtable.new
302
302
  #
303
- # table = bigtable.create_table("my-instance", "my-table") do |cfm|
303
+ # table = bigtable.create_table "my-instance", "my-table" do |cfm|
304
304
  # gc_rule = Google::Cloud::Bigtable::GcRule.intersection(
305
305
  # Google::Cloud::Bigtable::GcRule.max_age(1800),
306
306
  # Google::Cloud::Bigtable::GcRule.max_versions(3)
307
307
  # )
308
- # cfm.add("cf1", gc_rule: gc_rule)
308
+ # cfm.add "cf1", gc_rule: gc_rule
309
309
  # end
310
310
  #
311
311
  def self.intersection *rules
@@ -44,9 +44,9 @@ module Google
44
44
  # "my-instance",
45
45
  # display_name: "Instance for user data",
46
46
  # type: :DEVELOPMENT,
47
- # labels: { "env" => "dev"}
47
+ # labels: { "env" => "dev" }
48
48
  # ) do |clusters|
49
- # clusters.add("test-cluster", "us-east1-b") # nodes not allowed
49
+ # clusters.add "test-cluster", "us-east1-b" # nodes not allowed
50
50
  # end
51
51
  #
52
52
  # job.done? #=> false
@@ -203,7 +203,7 @@ module Google
203
203
  #
204
204
  # bigtable = Google::Cloud::Bigtable.new
205
205
  #
206
- # instance = bigtable.instance("my-instance")
206
+ # instance = bigtable.instance "my-instance"
207
207
  #
208
208
  # instance.development? # true
209
209
  # instance.type = :PRODUCTION
@@ -267,7 +267,7 @@ module Google
267
267
  #
268
268
  # bigtable = Google::Cloud::Bigtable.new
269
269
  #
270
- # instance = bigtable.instance("my-instance")
270
+ # instance = bigtable.instance "my-instance"
271
271
  # instance.display_name = "My app dev instance" # Set display name
272
272
  # instance.labels = { env: "dev", data: "users" }
273
273
  # job = instance.save
@@ -314,7 +314,7 @@ module Google
314
314
  #
315
315
  # bigtable = Google::Cloud::Bigtable.new
316
316
  #
317
- # instance = bigtable.instance("my-instance")
317
+ # instance = bigtable.instance "my-instance"
318
318
  # instance.delete
319
319
  #
320
320
  def delete
@@ -340,7 +340,7 @@ module Google
340
340
  #
341
341
  # bigtable = Google::Cloud::Bigtable.new
342
342
  #
343
- # instance = bigtable.instance("my-instance")
343
+ # instance = bigtable.instance "my-instance"
344
344
  #
345
345
  # instance.clusters.all do |cluster|
346
346
  # puts cluster.cluster_id
@@ -366,9 +366,9 @@ module Google
366
366
  #
367
367
  # bigtable = Google::Cloud::Bigtable.new
368
368
  #
369
- # instance = bigtable.instance("my-instance")
369
+ # instance = bigtable.instance "my-instance"
370
370
  #
371
- # cluster = instance.cluster("my-instance-cluster")
371
+ # cluster = instance.cluster "my-cluster"
372
372
  # puts cluster.cluster_id
373
373
  #
374
374
  def cluster cluster_id
@@ -403,7 +403,7 @@ module Google
403
403
  #
404
404
  # bigtable = Google::Cloud::Bigtable.new
405
405
  #
406
- # instance = bigtable.instance("my-instance")
406
+ # instance = bigtable.instance "my-instance"
407
407
  # job = instance.create_cluster(
408
408
  # "my-new-cluster",
409
409
  # "us-east-1b",
@@ -450,7 +450,7 @@ module Google
450
450
  #
451
451
  # bigtable = Google::Cloud::Bigtable.new
452
452
  #
453
- # instance = bigtable.instance("my-instance")
453
+ # instance = bigtable.instance "my-instance"
454
454
  #
455
455
  # # Default name-only view
456
456
  # instance.tables.all do |table|
@@ -490,14 +490,14 @@ module Google
490
490
  #
491
491
  # bigtable = Google::Cloud::Bigtable.new
492
492
  #
493
- # instance = bigtable.instance("my-instance")
493
+ # instance = bigtable.instance "my-instance"
494
494
  #
495
- # table = instance.table("my-table", perform_lookup: true)
495
+ # table = instance.table "my-table", perform_lookup: true
496
496
  # puts table.name
497
497
  # puts table.column_families
498
498
  #
499
499
  # # Name-only view
500
- # table = instance.table("my-table", view: :NAME_ONLY, perform_lookup: true)
500
+ # table = instance.table "my-table", view: :NAME_ONLY, perform_lookup: true
501
501
  # puts table.name
502
502
  #
503
503
  # @example Mutate rows.
@@ -505,17 +505,17 @@ module Google
505
505
  #
506
506
  # bigtable = Google::Cloud::Bigtable.new
507
507
  #
508
- # table = bigtable.table("my-instance", "my-table")
508
+ # table = bigtable.table "my-instance", "my-table"
509
509
  #
510
- # entry = table.new_mutation_entry("user-1")
510
+ # entry = table.new_mutation_entry "user-1"
511
511
  # entry.set_cell(
512
512
  # "cf1",
513
513
  # "field1",
514
514
  # "XYZ",
515
- # timestamp: (Time.now.to_f * 1000000).round(-3) # microseconds
516
- # ).delete_cells("cf2", "field02")
515
+ # timestamp: (Time.now.to_f * 1_000_000).round(-3) # microseconds
516
+ # ).delete_cells "cf2", "field02"
517
517
  #
518
- # table.mutate_row(entry)
518
+ # table.mutate_row entry
519
519
  #
520
520
  def table table_id, view: nil, perform_lookup: nil, app_profile_id: nil
521
521
  ensure_service!
@@ -581,9 +581,9 @@ module Google
581
581
  #
582
582
  # bigtable = Google::Cloud::Bigtable.new
583
583
  #
584
- # instance = bigtable.instance("my-instance")
584
+ # instance = bigtable.instance "my-instance"
585
585
  #
586
- # table = instance.create_table("my-table")
586
+ # table = instance.create_table "my-table"
587
587
  # puts table.name
588
588
  #
589
589
  # @example Create a table with initial splits and column families.
@@ -591,18 +591,18 @@ module Google
591
591
  #
592
592
  # bigtable = Google::Cloud::Bigtable.new
593
593
  #
594
- # instance = bigtable.instance("my-instance")
594
+ # instance = bigtable.instance "my-instance"
595
595
  #
596
596
  # initial_splits = ["user-00001", "user-100000", "others"]
597
- # table = instance.create_table("my-table", initial_splits: initial_splits) do |cfm|
598
- # cfm.add('cf1', gc_rule: Google::Cloud::Bigtable::GcRule.max_versions(5))
599
- # cfm.add('cf2', gc_rule: Google::Cloud::Bigtable::GcRule.max_age(600))
597
+ # table = instance.create_table "my-table", initial_splits: initial_splits do |cfm|
598
+ # cfm.add "cf1", gc_rule: Google::Cloud::Bigtable::GcRule.max_versions(5)
599
+ # cfm.add "cf2", gc_rule: Google::Cloud::Bigtable::GcRule.max_age(600)
600
600
  #
601
601
  # gc_rule = Google::Cloud::Bigtable::GcRule.union(
602
- # Google::Cloud::Bigtable::GcRule.max_age(1800),
602
+ # Google::Cloud::Bigtable::GcRule.max_age(1800),
603
603
  # Google::Cloud::Bigtable::GcRule.max_versions(3)
604
604
  # )
605
- # cfm.add('cf3', gc_rule: gc_rule)
605
+ # cfm.add "cf3", gc_rule: gc_rule
606
606
  # end
607
607
  #
608
608
  # puts table
@@ -660,10 +660,10 @@ module Google
660
660
  #
661
661
  # bigtable = Google::Cloud::Bigtable.new
662
662
  #
663
- # instance = bigtable.instance("my-instance")
663
+ # instance = bigtable.instance "my-instance"
664
664
  #
665
665
  # routing_policy = Google::Cloud::Bigtable::AppProfile.single_cluster_routing(
666
- # "my-instance-cluster-1",
666
+ # "my-cluster",
667
667
  # allow_transactional_writes: true
668
668
  # )
669
669
  #
@@ -679,7 +679,7 @@ module Google
679
679
  #
680
680
  # bigtable = Google::Cloud::Bigtable.new
681
681
  #
682
- # instance = bigtable.instance("my-instance")
682
+ # instance = bigtable.instance "my-instance"
683
683
  #
684
684
  # routing_policy = Google::Cloud::Bigtable::AppProfile.multi_cluster_routing
685
685
  #
@@ -695,7 +695,7 @@ module Google
695
695
  #
696
696
  # bigtable = Google::Cloud::Bigtable.new
697
697
  #
698
- # instance = bigtable.instance("my-instance")
698
+ # instance = bigtable.instance "my-instance"
699
699
  #
700
700
  # routing_policy = Google::Cloud::Bigtable::AppProfile.multi_cluster_routing
701
701
  #
@@ -746,9 +746,9 @@ module Google
746
746
  #
747
747
  # bigtable = Google::Cloud::Bigtable.new
748
748
  #
749
- # instance = bigtable.instance("my-instance")
749
+ # instance = bigtable.instance "my-instance"
750
750
  #
751
- # app_profile = instance.app_profile("my-app-profile")
751
+ # app_profile = instance.app_profile "my-app-profile"
752
752
  #
753
753
  # if app_profile
754
754
  # puts app_profile.name
@@ -776,7 +776,7 @@ module Google
776
776
  #
777
777
  # bigtable = Google::Cloud::Bigtable.new
778
778
  #
779
- # instance = bigtable.instance("my-instance")
779
+ # instance = bigtable.instance "my-instance"
780
780
  #
781
781
  # instance.app_profiles.all do |app_profile|
782
782
  # puts app_profile.name
@@ -808,17 +808,17 @@ module Google
808
808
  #
809
809
  # bigtable = Google::Cloud::Bigtable.new
810
810
  #
811
- # instance = bigtable.instance("my-instance")
811
+ # instance = bigtable.instance "my-instance"
812
812
  # policy = instance.policy
813
813
  #
814
814
  # @example Update the policy by passing a block.
815
815
  # require "google/cloud/bigtable"
816
816
  #
817
817
  # bigtable = Google::Cloud::Bigtable.new
818
- # instance = bigtable.instance("my-instance")
818
+ # instance = bigtable.instance "my-instance"
819
819
  #
820
820
  # instance.policy do |p|
821
- # p.add("roles/owner", "user:owner@example.com")
821
+ # p.add "roles/owner", "user:owner@example.com"
822
822
  # end # 2 API calls
823
823
  #
824
824
  def policy
@@ -849,11 +849,11 @@ module Google
849
849
  #
850
850
  # bigtable = Google::Cloud::Bigtable.new
851
851
  #
852
- # instance = bigtable.instance("my-instance")
852
+ # instance = bigtable.instance "my-instance"
853
853
  #
854
854
  # policy = instance.policy
855
- # policy.add("roles/owner", "user:owner@example.com")
856
- # updated_policy = instance.update_policy(policy)
855
+ # policy.add "roles/owner", "user:owner@example.com"
856
+ # updated_policy = instance.update_policy policy
857
857
  #
858
858
  # puts updated_policy.roles
859
859
  #
@@ -892,7 +892,7 @@ module Google
892
892
  #
893
893
  # bigtable = Google::Cloud::Bigtable.new
894
894
  #
895
- # instance = bigtable.instance("my-instance")
895
+ # instance = bigtable.instance "my-instance"
896
896
  #
897
897
  # permissions = instance.test_iam_permissions(
898
898
  # "bigtable.instances.get",
@@ -15,28 +15,31 @@
15
15
  # limitations under the License.
16
16
 
17
17
 
18
+ require "google/cloud/bigtable/admin/v2"
19
+
18
20
  module Google
19
21
  module Cloud
20
22
  module Bigtable
21
23
  class Instance
22
24
  ##
23
- # Instance::ClusterMap is a hash with cluster ID keys and cluster configuration values.
24
- # It is used to create a cluster.
25
+ # Instance::ClusterMap is a hash with cluster ID keys and cluster configuration values. It is used to create a
26
+ # cluster.
25
27
  #
26
28
  # @example
29
+ # require "google/cloud/bigtable"
27
30
  #
28
- # clusters = Google::Cloud::Bigtable::Instance::ClusterMap.new
31
+ # bigtable = Google::Cloud::Bigtable.new
29
32
  #
30
- # clusters.add("cluster-1", "us-east1-b", nodes: 3, storage_type: :SSD)
33
+ # job = bigtable.create_instance "my-instance" do |clusters|
34
+ # clusters.add "test-cluster", "us-east1-b", nodes: 3, storage_type: :SSD
35
+ # end
31
36
  #
32
- # # Or
33
- # clusters.add("cluster-2", "us-east1-b")
37
+ # job.wait_until_done!
34
38
  #
35
39
  class ClusterMap < DelegateClass(::Hash)
36
40
  # @private
37
41
  #
38
- # Creates a new Instance::ClusterMap with an hash of Cluster name and
39
- # cluster grpc instances.
42
+ # Creates a new Instance::ClusterMap with an hash of Cluster name and cluster grpc instances.
40
43
  def initialize value = {}
41
44
  super value
42
45
  end
@@ -45,24 +48,61 @@ module Google
45
48
  # Adds a cluster to the cluster map.
46
49
  #
47
50
  # @param name [String] The unique identifier for the cluster.
48
- # @param location [String]
49
- # The location where this cluster's nodes and storage reside. For best
50
- # performance, clients should be located as close as possible to this
51
- # cluster. Currently only zones are supported.
52
- # @param nodes [Integer] Number of nodes for the cluster. When creating
53
- # an instance of type `:DEVELOPMENT`, `nodes` must not be set.
54
- # @param storage_type [Symbol]
55
- # Valid values are:
56
- # * `:SSD`(Flash (SSD) storage should be used),
57
- # *`:HDD`(Magnetic drive (HDD) storage should be used)
51
+ # @param location [String] The location where this cluster's nodes and storage reside. For best performance,
52
+ # clients should be located as close as possible to this cluster. Currently only zones are supported.
53
+ # @param nodes [Integer] Number of nodes for the cluster. When creating an instance of type `:DEVELOPMENT`,
54
+ # `nodes` must not be set.
55
+ # @param storage_type [Symbol] The type of storage used by this cluster to serve its parent instance's tables,
56
+ # unless explicitly overridden. Valid values are:
57
+ #
58
+ # * `:SSD` - Flash (SSD) storage should be used.
59
+ # * `:HDD` - Magnetic drive (HDD) storage should be used.
60
+ #
61
+ # If not set then default will set to `:STORAGE_TYPE_UNSPECIFIED`.
62
+ # @param kms_key [String] The full name of a Cloud KMS encryption key for a CMEK-protected cluster, in the
63
+ # format `projects/{key_project_id}/locations/{location}/keyRings/{ring_name}/cryptoKeys/{key_name}`.
64
+ #
65
+ # The requirements for this key are:
66
+ #
67
+ # 1. The Cloud Bigtable service account associated with the project that contains this cluster must be
68
+ # granted the `cloudkms.cryptoKeyEncrypterDecrypter` role on the CMEK key.
69
+ # 2. Only regional keys can be used and the region of the CMEK key must match the region of the cluster.
70
+ # 3. All clusters within an instance must use the same CMEK key.
71
+ #
72
+ # @example
73
+ # require "google/cloud/bigtable"
74
+ #
75
+ # bigtable = Google::Cloud::Bigtable.new
76
+ #
77
+ # job = bigtable.create_instance "my-instance" do |clusters|
78
+ # clusters.add "test-cluster", "us-east1-b", nodes: 3, storage_type: :SSD
79
+ # end
80
+ #
81
+ # job.wait_until_done!
82
+ #
83
+ # @example With a Cloud KMS encryption key name for a CMEK-protected cluster:
84
+ # require "google/cloud/bigtable"
85
+ #
86
+ # bigtable = Google::Cloud::Bigtable.new
87
+ #
88
+ # kms_key_name = "projects/a/locations/b/keyRings/c/cryptoKeys/d"
89
+ # job = bigtable.create_instance "my-instance" do |clusters|
90
+ # clusters.add "test-cluster", "us-east1-b", kms_key: kms_key_name
91
+ # end
58
92
  #
59
- # If not set then default will set to `:STORAGE_TYPE_UNSPECIFIED`
93
+ # job.wait_until_done!
60
94
  #
61
- def add name, location, nodes: nil, storage_type: nil
95
+ def add name, location, nodes: nil, storage_type: nil, kms_key: nil
96
+ if kms_key
97
+ encryption_config = Google::Cloud::Bigtable::Admin::V2::Cluster::EncryptionConfig.new(
98
+ kms_key_name: kms_key
99
+ )
100
+ end
62
101
  attrs = {
63
102
  serve_nodes: nodes,
64
103
  location: location,
65
- default_storage_type: storage_type
104
+ default_storage_type: storage_type,
105
+ encryption_config: encryption_config
66
106
  }.delete_if { |_, v| v.nil? }
67
107
 
68
108
  self[name] = Google::Cloud::Bigtable::Admin::V2::Cluster.new attrs