google-cloud-bigtable 0.7.0 → 1.1.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.
- checksums.yaml +4 -4
- data/AUTHENTICATION.md +4 -26
- data/CHANGELOG.md +55 -0
- data/OVERVIEW.md +388 -19
- data/lib/google-cloud-bigtable.rb +0 -1
- data/lib/google/bigtable/admin/v2/bigtable_table_admin_services_pb.rb +1 -1
- data/lib/google/bigtable/v2/bigtable_pb.rb +3 -0
- data/lib/google/bigtable/v2/bigtable_services_pb.rb +1 -1
- data/lib/google/cloud/bigtable/admin.rb +2 -2
- data/lib/google/cloud/bigtable/admin/v2.rb +2 -2
- data/lib/google/cloud/bigtable/admin/v2/bigtable_instance_admin_client.rb +1 -1
- data/lib/google/cloud/bigtable/admin/v2/bigtable_table_admin_client.rb +2 -2
- data/lib/google/cloud/bigtable/admin/v2/credentials.rb +1 -1
- data/lib/google/cloud/bigtable/admin/v2/doc/google/bigtable/admin/v2/bigtable_instance_admin.rb +1 -1
- data/lib/google/cloud/bigtable/admin/v2/doc/google/bigtable/admin/v2/bigtable_table_admin.rb +1 -1
- data/lib/google/cloud/bigtable/admin/v2/doc/google/bigtable/admin/v2/instance.rb +1 -1
- data/lib/google/cloud/bigtable/admin/v2/doc/google/bigtable/admin/v2/table.rb +1 -1
- data/lib/google/cloud/bigtable/admin/v2/doc/google/iam/v1/iam_policy.rb +1 -1
- data/lib/google/cloud/bigtable/admin/v2/doc/google/iam/v1/options.rb +1 -1
- data/lib/google/cloud/bigtable/admin/v2/doc/google/iam/v1/policy.rb +7 -6
- data/lib/google/cloud/bigtable/admin/v2/doc/google/longrunning/operations.rb +2 -2
- data/lib/google/cloud/bigtable/admin/v2/doc/google/protobuf/any.rb +1 -1
- data/lib/google/cloud/bigtable/admin/v2/doc/google/protobuf/duration.rb +1 -1
- data/lib/google/cloud/bigtable/admin/v2/doc/google/protobuf/empty.rb +1 -1
- data/lib/google/cloud/bigtable/admin/v2/doc/google/protobuf/field_mask.rb +1 -1
- data/lib/google/cloud/bigtable/admin/v2/doc/google/protobuf/timestamp.rb +1 -1
- data/lib/google/cloud/bigtable/admin/v2/doc/google/rpc/status.rb +7 -55
- data/lib/google/cloud/bigtable/admin/v2/doc/google/type/expr.rb +1 -1
- data/lib/google/cloud/bigtable/app_profile.rb +13 -13
- data/lib/google/cloud/bigtable/app_profile/list.rb +7 -7
- data/lib/google/cloud/bigtable/chunk_processor.rb +1 -1
- data/lib/google/cloud/bigtable/cluster.rb +7 -7
- data/lib/google/cloud/bigtable/cluster/list.rb +2 -2
- data/lib/google/cloud/bigtable/column_family.rb +3 -9
- data/lib/google/cloud/bigtable/column_family_map.rb +8 -8
- data/lib/google/cloud/bigtable/column_range.rb +6 -6
- data/lib/google/cloud/bigtable/gc_rule.rb +8 -8
- data/lib/google/cloud/bigtable/instance.rb +78 -71
- data/lib/google/cloud/bigtable/instance/cluster_map.rb +8 -6
- data/lib/google/cloud/bigtable/instance/job.rb +2 -2
- data/lib/google/cloud/bigtable/instance/list.rb +4 -4
- data/lib/google/cloud/bigtable/longrunning_job.rb +1 -1
- data/lib/google/cloud/bigtable/mutation_entry.rb +17 -16
- data/lib/google/cloud/bigtable/mutation_operations.rb +13 -49
- data/lib/google/cloud/bigtable/policy.rb +1 -1
- data/lib/google/cloud/bigtable/project.rb +28 -59
- data/lib/google/cloud/bigtable/read_modify_write_rule.rb +6 -6
- data/lib/google/cloud/bigtable/read_operations.rb +15 -19
- data/lib/google/cloud/bigtable/routing_policy.rb +3 -2
- data/lib/google/cloud/bigtable/row.rb +14 -14
- data/lib/google/cloud/bigtable/row_filter.rb +31 -15
- data/lib/google/cloud/bigtable/row_filter/chain_filter.rb +49 -26
- data/lib/google/cloud/bigtable/row_filter/condition_filter.rb +4 -1
- data/lib/google/cloud/bigtable/row_filter/interleave_filter.rb +44 -24
- data/lib/google/cloud/bigtable/row_filter/simple_filter.rb +3 -3
- data/lib/google/cloud/bigtable/rows_mutator.rb +1 -5
- data/lib/google/cloud/bigtable/rows_reader.rb +5 -4
- data/lib/google/cloud/bigtable/sample_row_key.rb +1 -1
- data/lib/google/cloud/bigtable/service.rb +94 -14
- data/lib/google/cloud/bigtable/table.rb +130 -27
- data/lib/google/cloud/bigtable/table/cluster_state.rb +10 -5
- data/lib/google/cloud/bigtable/table/list.rb +2 -2
- data/lib/google/cloud/bigtable/v2.rb +2 -2
- data/lib/google/cloud/bigtable/v2/bigtable_client.rb +13 -13
- data/lib/google/cloud/bigtable/v2/credentials.rb +1 -1
- data/lib/google/cloud/bigtable/v2/doc/google/bigtable/v2/bigtable.rb +17 -14
- data/lib/google/cloud/bigtable/v2/doc/google/bigtable/v2/data.rb +1 -1
- data/lib/google/cloud/bigtable/v2/doc/google/protobuf/any.rb +1 -1
- data/lib/google/cloud/bigtable/v2/doc/google/protobuf/wrappers.rb +1 -1
- data/lib/google/cloud/bigtable/v2/doc/google/rpc/status.rb +7 -55
- data/lib/google/cloud/bigtable/value_range.rb +14 -13
- data/lib/google/cloud/bigtable/version.rb +1 -1
- metadata +42 -2
|
@@ -102,7 +102,7 @@ module Google
|
|
|
102
102
|
#
|
|
103
103
|
def sample probability
|
|
104
104
|
if probability >= 1 || probability <= 0
|
|
105
|
-
raise RowFilterError, "Probability must be
|
|
105
|
+
raise RowFilterError, "Probability must be greater than 0 and less than 1.0."
|
|
106
106
|
end
|
|
107
107
|
@grpc.row_sample_filter = probability
|
|
108
108
|
self
|
|
@@ -165,7 +165,7 @@ module Google
|
|
|
165
165
|
#
|
|
166
166
|
# Due to a technical limitation, it is not possible to apply
|
|
167
167
|
# multiple labels to a cell. As a result, a chain may have no more than
|
|
168
|
-
# one sub-filter
|
|
168
|
+
# one sub-filter that contains an `apply_label_transformer`. It is okay for
|
|
169
169
|
# an interleave to contain multiple `apply_label_transformers`, as they
|
|
170
170
|
# will be applied to separate copies of the input.
|
|
171
171
|
#
|
|
@@ -220,7 +220,7 @@ module Google
|
|
|
220
220
|
end
|
|
221
221
|
|
|
222
222
|
##
|
|
223
|
-
# Creates a timestamp-range filter
|
|
223
|
+
# Creates a timestamp-range filter.
|
|
224
224
|
#
|
|
225
225
|
# Matches only cells with timestamps within the given range.
|
|
226
226
|
# Specifies a contiguous range of timestamps.
|
|
@@ -83,14 +83,10 @@ module Google
|
|
|
83
83
|
# @return [Array<Google::Bigtable::V2::MutateRowsResponse::Entry>]
|
|
84
84
|
#
|
|
85
85
|
def mutate_rows entries
|
|
86
|
-
response = @table.
|
|
86
|
+
response = @table.service.mutate_rows @table.path, entries, app_profile_id: @table.app_profile_id
|
|
87
87
|
response.each_with_object [] do |res, statuses|
|
|
88
88
|
statuses.concat res.entries
|
|
89
89
|
end
|
|
90
|
-
rescue Google::Gax::GaxError => e
|
|
91
|
-
raise Google::Cloud::Error.from_error(e.cause)
|
|
92
|
-
rescue GRPC::BadStatus => e
|
|
93
|
-
raise Google::Cloud::Error.from_error(e)
|
|
94
90
|
end
|
|
95
91
|
|
|
96
92
|
##
|
|
@@ -23,7 +23,7 @@ module Google
|
|
|
23
23
|
# @private
|
|
24
24
|
# # RowsReader
|
|
25
25
|
#
|
|
26
|
-
#
|
|
26
|
+
# Retryable read rows helper
|
|
27
27
|
#
|
|
28
28
|
class RowsReader
|
|
29
29
|
# @private
|
|
@@ -75,8 +75,9 @@ module Google
|
|
|
75
75
|
# Array of row or yield block for each processed row.
|
|
76
76
|
#
|
|
77
77
|
def read rows: nil, filter: nil, rows_limit: nil
|
|
78
|
-
response = @table.
|
|
79
|
-
@table.
|
|
78
|
+
response = @table.service.read_rows(
|
|
79
|
+
@table.instance_id,
|
|
80
|
+
@table.table_id,
|
|
80
81
|
rows: rows,
|
|
81
82
|
filter: filter,
|
|
82
83
|
rows_limit: rows_limit,
|
|
@@ -105,7 +106,7 @@ module Google
|
|
|
105
106
|
end
|
|
106
107
|
|
|
107
108
|
##
|
|
108
|
-
#
|
|
109
|
+
# Calculates and returns the read rows limit and row set based on last read key.
|
|
109
110
|
#
|
|
110
111
|
# @param rows_limit [Integer]
|
|
111
112
|
# The read will terminate after committing to N rows' worth of results.
|
|
@@ -31,7 +31,7 @@ module Google
|
|
|
31
31
|
# Note: that row keys in this list may not have ever been written to or read
|
|
32
32
|
# from, and users should therefore not make any assumptions about the row key
|
|
33
33
|
# structure that are specific to their use case.
|
|
34
|
-
|
|
34
|
+
#
|
|
35
35
|
# * offset_bytes : Approximate total storage space used by all rows in the table which precede
|
|
36
36
|
# `row_key`. Buffering the contents of all rows between two subsequent
|
|
37
37
|
# samples would require space roughly equal to the difference in their
|
|
@@ -640,6 +640,100 @@ module Google
|
|
|
640
640
|
end
|
|
641
641
|
end
|
|
642
642
|
|
|
643
|
+
##
|
|
644
|
+
# Gets the access control policy for an table resource. Returns an empty
|
|
645
|
+
# policy if an table exists but does not have a policy set.
|
|
646
|
+
#
|
|
647
|
+
# @param table_id [String]
|
|
648
|
+
# Unique ID of the table for which the policy is being requested.
|
|
649
|
+
# @return [Google::Iam::V1::Policy]
|
|
650
|
+
#
|
|
651
|
+
def get_table_policy instance_id, table_id
|
|
652
|
+
execute do
|
|
653
|
+
tables.get_iam_policy table_path(instance_id, table_id)
|
|
654
|
+
end
|
|
655
|
+
end
|
|
656
|
+
|
|
657
|
+
##
|
|
658
|
+
# Sets the access control policy on an table resource. Replaces any
|
|
659
|
+
# existing policy.
|
|
660
|
+
#
|
|
661
|
+
# @param table_id [String]
|
|
662
|
+
# Unique ID of the table the policy is for.
|
|
663
|
+
# @param policy [Google::Iam::V1::Policy | Hash]
|
|
664
|
+
# REQUIRED: The complete policy to be applied to the +resource+. The size of
|
|
665
|
+
# the policy is limited to a few 10s of KB. An empty policy is valid
|
|
666
|
+
# for Cloud Bigtable, but certain Cloud Platform services (such as Projects)
|
|
667
|
+
# might reject an empty policy.
|
|
668
|
+
# Alternatively, provide a hash similar to `Google::Iam::V1::Policy`.
|
|
669
|
+
# @return [Google::Iam::V1::Policy]
|
|
670
|
+
#
|
|
671
|
+
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
|
|
675
|
+
end
|
|
676
|
+
|
|
677
|
+
##
|
|
678
|
+
# Returns permissions that the caller has for the specified table resource.
|
|
679
|
+
#
|
|
680
|
+
# @param table_id [String]
|
|
681
|
+
# The table ID that the policy detail is being requested for.
|
|
682
|
+
# @param permissions [Array<String>]
|
|
683
|
+
# The set of permissions to check for the +resource+. Permissions with
|
|
684
|
+
# wildcards (such as '*' or 'storage.*') are not allowed. For more
|
|
685
|
+
# information see
|
|
686
|
+
# [IAM Overview](https://cloud.google.com/iam/docs/overview#permissions).
|
|
687
|
+
# @return [Google::Iam::V1::TestIamPermissionsResponse]
|
|
688
|
+
#
|
|
689
|
+
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
|
|
693
|
+
end
|
|
694
|
+
|
|
695
|
+
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),
|
|
698
|
+
rows: rows,
|
|
699
|
+
filter: filter,
|
|
700
|
+
rows_limit: rows_limit,
|
|
701
|
+
app_profile_id: app_profile_id
|
|
702
|
+
end
|
|
703
|
+
|
|
704
|
+
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
|
|
708
|
+
end
|
|
709
|
+
|
|
710
|
+
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
|
|
714
|
+
end
|
|
715
|
+
|
|
716
|
+
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
|
|
720
|
+
end
|
|
721
|
+
|
|
722
|
+
def check_and_mutate_row table_name, row_key, app_profile_id: nil, predicate_filter: nil, true_mutations: nil,
|
|
723
|
+
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
|
|
729
|
+
end
|
|
730
|
+
|
|
731
|
+
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
|
|
735
|
+
end
|
|
736
|
+
|
|
643
737
|
##
|
|
644
738
|
# Executes the API call and wrap errors to {Google::Cloud::Error}.
|
|
645
739
|
#
|
|
@@ -714,20 +808,6 @@ module Google
|
|
|
714
808
|
Admin::V2::BigtableTableAdminClient.table_path project_id, instance_id, table_id
|
|
715
809
|
end
|
|
716
810
|
|
|
717
|
-
##
|
|
718
|
-
# Creates a formatted snapshot path.
|
|
719
|
-
#
|
|
720
|
-
# @param instance_id [String]
|
|
721
|
-
# @param cluster_id [String]
|
|
722
|
-
# @param snapshot_id [String]
|
|
723
|
-
# @return [String]
|
|
724
|
-
# Formatted snapshot path
|
|
725
|
-
# +projects/<project>/instances/<instance>/clusters/<cluster>/snapshots/<snapshot>+
|
|
726
|
-
#
|
|
727
|
-
def snapshot_path instance_id, cluster_id, snapshot_id
|
|
728
|
-
Admin::V2::BigtableTableAdminClient.snapshot_path project_id, instance_id, cluster_id, snapshot_id
|
|
729
|
-
end
|
|
730
|
-
|
|
731
811
|
##
|
|
732
812
|
# Creates a formatted app profile path.
|
|
733
813
|
#
|
|
@@ -20,6 +20,7 @@ require "google/cloud/bigtable/table/cluster_state"
|
|
|
20
20
|
require "google/cloud/bigtable/column_family_map"
|
|
21
21
|
require "google/cloud/bigtable/gc_rule"
|
|
22
22
|
require "google/cloud/bigtable/mutation_operations"
|
|
23
|
+
require "google/cloud/bigtable/policy"
|
|
23
24
|
require "google/cloud/bigtable/read_operations"
|
|
24
25
|
|
|
25
26
|
module Google
|
|
@@ -70,7 +71,7 @@ module Google
|
|
|
70
71
|
end
|
|
71
72
|
|
|
72
73
|
##
|
|
73
|
-
# The unique identifier for the project.
|
|
74
|
+
# The unique identifier for the project to which the table belongs.
|
|
74
75
|
#
|
|
75
76
|
# @return [String]
|
|
76
77
|
#
|
|
@@ -79,7 +80,7 @@ module Google
|
|
|
79
80
|
end
|
|
80
81
|
|
|
81
82
|
##
|
|
82
|
-
# The unique identifier for the instance.
|
|
83
|
+
# The unique identifier for the instance to which the table belongs.
|
|
83
84
|
#
|
|
84
85
|
# @return [String]
|
|
85
86
|
#
|
|
@@ -108,16 +109,16 @@ module Google
|
|
|
108
109
|
end
|
|
109
110
|
|
|
110
111
|
##
|
|
111
|
-
#
|
|
112
|
+
# Reloads table data.
|
|
112
113
|
#
|
|
113
114
|
# @param view [Symbol] Table view type.
|
|
114
|
-
# Default view type is `:SCHEMA_VIEW
|
|
115
|
+
# Default view type is `:SCHEMA_VIEW`.
|
|
115
116
|
# Valid view types are:
|
|
116
117
|
#
|
|
117
|
-
# * `:NAME_ONLY` - Only populates `name
|
|
118
|
-
# * `:SCHEMA_VIEW` - Only populates `name` and fields related to the table's schema
|
|
118
|
+
# * `:NAME_ONLY` - Only populates `name`.
|
|
119
|
+
# * `:SCHEMA_VIEW` - Only populates `name` and fields related to the table's schema.
|
|
119
120
|
# * `:REPLICATION_VIEW` - Only populates `name` and fields related to the table's replication state.
|
|
120
|
-
# * `:FULL` - Populates all fields
|
|
121
|
+
# * `:FULL` - Populates all fields.
|
|
121
122
|
#
|
|
122
123
|
# @return [Google::Cloud::Bigtable::Table]
|
|
123
124
|
#
|
|
@@ -132,7 +133,7 @@ module Google
|
|
|
132
133
|
# If it could not be determined whether or not the table has data in a
|
|
133
134
|
# particular cluster (for example, if its zone is unavailable), then
|
|
134
135
|
# there will be an entry for the cluster with UNKNOWN `replication_status`.
|
|
135
|
-
# Views: `FULL
|
|
136
|
+
# Views: `FULL`.
|
|
136
137
|
#
|
|
137
138
|
# @return [Array<Google::Cloud::Bigtable::Table::ClusterState>]
|
|
138
139
|
#
|
|
@@ -221,7 +222,7 @@ module Google
|
|
|
221
222
|
# The granularity (e.g. `MILLIS`, `MICROS`) at which timestamps are stored in
|
|
222
223
|
# this table. Timestamps not matching the granularity will be rejected.
|
|
223
224
|
# If unspecified at creation time, the value will be set to `MILLIS`.
|
|
224
|
-
# Views: `SCHEMA_VIEW`, `FULL
|
|
225
|
+
# Views: `SCHEMA_VIEW`, `FULL`.
|
|
225
226
|
#
|
|
226
227
|
# @return [Symbol]
|
|
227
228
|
#
|
|
@@ -239,6 +240,117 @@ module Google
|
|
|
239
240
|
granularity == :MILLIS
|
|
240
241
|
end
|
|
241
242
|
|
|
243
|
+
##
|
|
244
|
+
# Gets the [Cloud IAM](https://cloud.google.com/iam/) access control
|
|
245
|
+
# policy for the table.
|
|
246
|
+
#
|
|
247
|
+
# @see https://cloud.google.com/bigtable/docs/access-control
|
|
248
|
+
#
|
|
249
|
+
# @yield [policy] A block for updating the policy. The latest policy
|
|
250
|
+
# will be read from the Bigtable service and passed to the block. After
|
|
251
|
+
# the block completes, the modified policy will be written to the
|
|
252
|
+
# service.
|
|
253
|
+
# @yieldparam [Policy] policy the current Cloud IAM Policy for this
|
|
254
|
+
# table.
|
|
255
|
+
#
|
|
256
|
+
# @return [Policy] The current Cloud IAM Policy for the table.
|
|
257
|
+
#
|
|
258
|
+
# @example
|
|
259
|
+
# require "google/cloud/bigtable"
|
|
260
|
+
#
|
|
261
|
+
# bigtable = Google::Cloud::Bigtable.new
|
|
262
|
+
#
|
|
263
|
+
# table = bigtable.table("my-instance", "my-table", perform_lookup: true)
|
|
264
|
+
# policy = table.policy
|
|
265
|
+
#
|
|
266
|
+
# @example Update the policy by passing a block.
|
|
267
|
+
# require "google/cloud/bigtable"
|
|
268
|
+
#
|
|
269
|
+
# bigtable = Google::Cloud::Bigtable.new
|
|
270
|
+
#
|
|
271
|
+
# table = bigtable.table("my-instance", "my-table", perform_lookup: true)
|
|
272
|
+
#
|
|
273
|
+
# table.policy do |p|
|
|
274
|
+
# p.add("roles/owner", "user:owner@example.com")
|
|
275
|
+
# end # 2 API calls
|
|
276
|
+
#
|
|
277
|
+
def policy
|
|
278
|
+
ensure_service!
|
|
279
|
+
grpc = service.get_table_policy instance_id, name
|
|
280
|
+
policy = Policy.from_grpc grpc
|
|
281
|
+
return policy unless block_given?
|
|
282
|
+
yield policy
|
|
283
|
+
update_policy policy
|
|
284
|
+
end
|
|
285
|
+
|
|
286
|
+
##
|
|
287
|
+
# Updates the [Cloud IAM](https://cloud.google.com/iam/) access control
|
|
288
|
+
# policy for the table. The policy should be read from {#policy}.
|
|
289
|
+
# See {Google::Cloud::Bigtable::Policy} for an explanation of the policy
|
|
290
|
+
# `etag` property and how to modify policies.
|
|
291
|
+
#
|
|
292
|
+
# You can also update the policy by passing a block to {#policy}, which
|
|
293
|
+
# will call this method internally after the block completes.
|
|
294
|
+
#
|
|
295
|
+
# @param new_policy [Policy] a new or modified Cloud IAM Policy for this
|
|
296
|
+
# table
|
|
297
|
+
#
|
|
298
|
+
# @return [Policy] The policy returned by the API update operation.
|
|
299
|
+
#
|
|
300
|
+
# @example
|
|
301
|
+
# require "google/cloud/bigtable"
|
|
302
|
+
#
|
|
303
|
+
# bigtable = Google::Cloud::Bigtable.new
|
|
304
|
+
#
|
|
305
|
+
# table = bigtable.table("my-instance", "my-table", perform_lookup: true)
|
|
306
|
+
#
|
|
307
|
+
# policy = table.policy
|
|
308
|
+
# policy.add("roles/owner", "user:owner@example.com")
|
|
309
|
+
# updated_policy = table.update_policy(policy)
|
|
310
|
+
#
|
|
311
|
+
# puts updated_policy.roles
|
|
312
|
+
#
|
|
313
|
+
def update_policy new_policy
|
|
314
|
+
ensure_service!
|
|
315
|
+
grpc = service.set_table_policy instance_id, name, new_policy.to_grpc
|
|
316
|
+
Policy.from_grpc grpc
|
|
317
|
+
end
|
|
318
|
+
alias policy= update_policy
|
|
319
|
+
|
|
320
|
+
##
|
|
321
|
+
# Tests the specified permissions against the [Cloud
|
|
322
|
+
# IAM](https://cloud.google.com/iam/) access control policy.
|
|
323
|
+
#
|
|
324
|
+
# @see https://cloud.google.com/iam/docs/managing-policies Managing Policies
|
|
325
|
+
# @see https://cloud.google.com/bigtable/docs/access-control Access Control
|
|
326
|
+
#
|
|
327
|
+
# @param permissions [String, Array<String>] permissions The set of permissions to
|
|
328
|
+
# check access for. Permissions with wildcards (such as `*` or
|
|
329
|
+
# `bigtable.*`) are not allowed.
|
|
330
|
+
# See [Access Control](https://cloud.google.com/bigtable/docs/access-control).
|
|
331
|
+
#
|
|
332
|
+
# @return [Array<String>] The permissions that are configured for the policy.
|
|
333
|
+
#
|
|
334
|
+
# @example
|
|
335
|
+
# require "google/cloud/bigtable"
|
|
336
|
+
#
|
|
337
|
+
# bigtable = Google::Cloud::Bigtable.new
|
|
338
|
+
#
|
|
339
|
+
# table = bigtable.table("my-instance", "my-table", perform_lookup: true)
|
|
340
|
+
#
|
|
341
|
+
# permissions = table.test_iam_permissions(
|
|
342
|
+
# "bigtable.tables.delete",
|
|
343
|
+
# "bigtable.tables.get"
|
|
344
|
+
# )
|
|
345
|
+
# permissions.include? "bigtable.tables.delete" #=> false
|
|
346
|
+
# permissions.include? "bigtable.tables.get" #=> true
|
|
347
|
+
#
|
|
348
|
+
def test_iam_permissions *permissions
|
|
349
|
+
ensure_service!
|
|
350
|
+
grpc = service.test_table_permissions instance_id, name, permissions.flatten
|
|
351
|
+
grpc.permissions.to_a
|
|
352
|
+
end
|
|
353
|
+
|
|
242
354
|
##
|
|
243
355
|
# Permanently deletes the table from a instance.
|
|
244
356
|
#
|
|
@@ -334,7 +446,7 @@ module Google
|
|
|
334
446
|
# before this call started have been replicated. The tokens will be available
|
|
335
447
|
# for 90 days.
|
|
336
448
|
#
|
|
337
|
-
# @return [String]
|
|
449
|
+
# @return [String] The generated consistency token
|
|
338
450
|
#
|
|
339
451
|
# @example
|
|
340
452
|
# require "google/cloud/bigtable"
|
|
@@ -357,7 +469,7 @@ module Google
|
|
|
357
469
|
# considered consistent if replication has caught up based on the conditions
|
|
358
470
|
# specified in the token and the check request.
|
|
359
471
|
# @param token [String] Consistency token
|
|
360
|
-
# @return [Boolean]
|
|
472
|
+
# @return [Boolean] `true` if replication is consistent
|
|
361
473
|
#
|
|
362
474
|
# @example
|
|
363
475
|
# require "google/cloud/bigtable"
|
|
@@ -383,7 +495,7 @@ module Google
|
|
|
383
495
|
# Wait for replication to check replication consistency.
|
|
384
496
|
# Checks replication consistency by generating a consistency token and
|
|
385
497
|
# making the `check_consistency` API call 5 times (by default).
|
|
386
|
-
# If the response is consistent, returns true
|
|
498
|
+
# If the response is consistent, returns `true`. Otherwise tries again
|
|
387
499
|
# repeatedly until the timeout. If the check does not succeed by the
|
|
388
500
|
# timeout, returns `false`.
|
|
389
501
|
#
|
|
@@ -391,7 +503,7 @@ module Google
|
|
|
391
503
|
# Timeout in seconds. Defaults value is 600 seconds.
|
|
392
504
|
# @param check_interval [Integer]
|
|
393
505
|
# Consistency check interval in seconds. Default is 5 seconds.
|
|
394
|
-
# @return [Boolean]
|
|
506
|
+
# @return [Boolean] `true` if replication is consistent
|
|
395
507
|
#
|
|
396
508
|
# @example
|
|
397
509
|
# require "google/cloud/bigtable"
|
|
@@ -410,7 +522,7 @@ module Google
|
|
|
410
522
|
# end
|
|
411
523
|
#
|
|
412
524
|
def wait_for_replication timeout: 600, check_interval: 5
|
|
413
|
-
raise InvalidArgumentError, "'check_interval'
|
|
525
|
+
raise InvalidArgumentError, "'check_interval' cannot be greater than timeout" if check_interval > timeout
|
|
414
526
|
token = generate_consistency_token
|
|
415
527
|
status = false
|
|
416
528
|
start_at = Time.now
|
|
@@ -424,19 +536,10 @@ module Google
|
|
|
424
536
|
status
|
|
425
537
|
end
|
|
426
538
|
|
|
427
|
-
# @private
|
|
428
|
-
# Gets the data client instance.
|
|
429
|
-
#
|
|
430
|
-
# @return [Google::Cloud::Bigtable::V2::BigtableClient]
|
|
431
|
-
#
|
|
432
|
-
def client
|
|
433
|
-
service.client
|
|
434
|
-
end
|
|
435
|
-
|
|
436
539
|
##
|
|
437
540
|
# Deletes all rows.
|
|
438
541
|
#
|
|
439
|
-
# @param timeout [Integer] Call timeout in seconds
|
|
542
|
+
# @param timeout [Integer] Call timeout in seconds.
|
|
440
543
|
# Use in case of insufficient deadline for DropRowRange, then
|
|
441
544
|
# try again with a longer request deadline.
|
|
442
545
|
# @return [Boolean]
|
|
@@ -460,8 +563,8 @@ module Google
|
|
|
460
563
|
##
|
|
461
564
|
# Deletes rows using row key prefix.
|
|
462
565
|
#
|
|
463
|
-
# @param prefix [String] Row key prefix (for example, "user")
|
|
464
|
-
# @param timeout [Integer] Call timeout in seconds
|
|
566
|
+
# @param prefix [String] Row key prefix (for example, "user").
|
|
567
|
+
# @param timeout [Integer] Call timeout in seconds.
|
|
465
568
|
# @return [Boolean]
|
|
466
569
|
# @example
|
|
467
570
|
# require "google/cloud/bigtable"
|
|
@@ -482,7 +585,7 @@ module Google
|
|
|
482
585
|
##
|
|
483
586
|
# Drops row range by row key prefix or deletes all.
|
|
484
587
|
#
|
|
485
|
-
# @param row_key_prefix [String] Row key prefix (for example, "user")
|
|
588
|
+
# @param row_key_prefix [String] Row key prefix (for example, "user").
|
|
486
589
|
# @param delete_all_data [Boolean]
|
|
487
590
|
# @return [Boolean]
|
|
488
591
|
#
|