google-cloud-bigtable 1.3.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 +7 -0
- data/.yardopts +19 -0
- data/AUTHENTICATION.md +177 -0
- data/CHANGELOG.md +223 -0
- data/CODE_OF_CONDUCT.md +40 -0
- data/CONTRIBUTING.md +188 -0
- data/EMULATOR.md +30 -0
- data/LICENSE +201 -0
- data/LOGGING.md +32 -0
- data/OVERVIEW.md +400 -0
- data/TROUBLESHOOTING.md +31 -0
- data/lib/google-cloud-bigtable.rb +171 -0
- data/lib/google/bigtable/admin/v2/bigtable_instance_admin_pb.rb +145 -0
- data/lib/google/bigtable/admin/v2/bigtable_instance_admin_services_pb.rb +90 -0
- data/lib/google/bigtable/admin/v2/bigtable_table_admin_pb.rb +208 -0
- data/lib/google/bigtable/admin/v2/bigtable_table_admin_services_pb.rb +154 -0
- data/lib/google/bigtable/admin/v2/common_pb.rb +30 -0
- data/lib/google/bigtable/admin/v2/instance_pb.rb +74 -0
- data/lib/google/bigtable/admin/v2/table_pb.rb +127 -0
- data/lib/google/bigtable/v2/bigtable_pb.rb +113 -0
- data/lib/google/bigtable/v2/bigtable_services_pb.rb +68 -0
- data/lib/google/bigtable/v2/data_pb.rb +156 -0
- data/lib/google/cloud/bigtable.rb +184 -0
- data/lib/google/cloud/bigtable/admin.rb +202 -0
- data/lib/google/cloud/bigtable/admin/credentials.rb +27 -0
- data/lib/google/cloud/bigtable/admin/v2.rb +223 -0
- data/lib/google/cloud/bigtable/admin/v2/bigtable_instance_admin_client.rb +1451 -0
- data/lib/google/cloud/bigtable/admin/v2/bigtable_instance_admin_client_config.json +139 -0
- data/lib/google/cloud/bigtable/admin/v2/bigtable_table_admin_client.rb +1734 -0
- data/lib/google/cloud/bigtable/admin/v2/bigtable_table_admin_client_config.json +163 -0
- data/lib/google/cloud/bigtable/admin/v2/credentials.rb +51 -0
- data/lib/google/cloud/bigtable/admin/v2/doc/google/bigtable/admin/v2/bigtable_instance_admin.rb +297 -0
- data/lib/google/cloud/bigtable/admin/v2/doc/google/bigtable/admin/v2/bigtable_table_admin.rb +587 -0
- data/lib/google/cloud/bigtable/admin/v2/doc/google/bigtable/admin/v2/instance.rb +193 -0
- data/lib/google/cloud/bigtable/admin/v2/doc/google/bigtable/admin/v2/table.rb +303 -0
- data/lib/google/cloud/bigtable/admin/v2/doc/google/iam/v1/iam_policy.rb +64 -0
- data/lib/google/cloud/bigtable/admin/v2/doc/google/iam/v1/options.rb +33 -0
- data/lib/google/cloud/bigtable/admin/v2/doc/google/iam/v1/policy.rb +151 -0
- data/lib/google/cloud/bigtable/admin/v2/doc/google/longrunning/operations.rb +51 -0
- data/lib/google/cloud/bigtable/admin/v2/doc/google/protobuf/any.rb +131 -0
- data/lib/google/cloud/bigtable/admin/v2/doc/google/protobuf/duration.rb +91 -0
- data/lib/google/cloud/bigtable/admin/v2/doc/google/protobuf/empty.rb +29 -0
- data/lib/google/cloud/bigtable/admin/v2/doc/google/protobuf/field_mask.rb +222 -0
- data/lib/google/cloud/bigtable/admin/v2/doc/google/protobuf/timestamp.rb +113 -0
- data/lib/google/cloud/bigtable/admin/v2/doc/google/rpc/status.rb +39 -0
- data/lib/google/cloud/bigtable/admin/v2/doc/google/type/expr.rb +45 -0
- data/lib/google/cloud/bigtable/app_profile.rb +439 -0
- data/lib/google/cloud/bigtable/app_profile/job.rb +99 -0
- data/lib/google/cloud/bigtable/app_profile/list.rb +165 -0
- data/lib/google/cloud/bigtable/backup.rb +324 -0
- data/lib/google/cloud/bigtable/backup/job.rb +87 -0
- data/lib/google/cloud/bigtable/backup/list.rb +167 -0
- data/lib/google/cloud/bigtable/chunk_processor.rb +241 -0
- data/lib/google/cloud/bigtable/cluster.rb +390 -0
- data/lib/google/cloud/bigtable/cluster/job.rb +88 -0
- data/lib/google/cloud/bigtable/cluster/list.rb +171 -0
- data/lib/google/cloud/bigtable/column_family.rb +73 -0
- data/lib/google/cloud/bigtable/column_family_map.rb +426 -0
- data/lib/google/cloud/bigtable/column_range.rb +194 -0
- data/lib/google/cloud/bigtable/convert.rb +83 -0
- data/lib/google/cloud/bigtable/credentials.rb +25 -0
- data/lib/google/cloud/bigtable/errors.rb +38 -0
- data/lib/google/cloud/bigtable/gc_rule.rb +334 -0
- data/lib/google/cloud/bigtable/instance.rb +935 -0
- data/lib/google/cloud/bigtable/instance/cluster_map.rb +74 -0
- data/lib/google/cloud/bigtable/instance/job.rb +98 -0
- data/lib/google/cloud/bigtable/instance/list.rb +164 -0
- data/lib/google/cloud/bigtable/longrunning_job.rb +122 -0
- data/lib/google/cloud/bigtable/mutation_entry.rb +256 -0
- data/lib/google/cloud/bigtable/mutation_operations.rb +357 -0
- data/lib/google/cloud/bigtable/policy.rb +167 -0
- data/lib/google/cloud/bigtable/project.rb +471 -0
- data/lib/google/cloud/bigtable/read_modify_write_rule.rb +134 -0
- data/lib/google/cloud/bigtable/read_operations.rb +328 -0
- data/lib/google/cloud/bigtable/routing_policy.rb +172 -0
- data/lib/google/cloud/bigtable/row.rb +136 -0
- data/lib/google/cloud/bigtable/row_filter.rb +639 -0
- data/lib/google/cloud/bigtable/row_filter/chain_filter.rb +590 -0
- data/lib/google/cloud/bigtable/row_filter/condition_filter.rb +114 -0
- data/lib/google/cloud/bigtable/row_filter/interleave_filter.rb +621 -0
- data/lib/google/cloud/bigtable/row_filter/simple_filter.rb +287 -0
- data/lib/google/cloud/bigtable/row_range.rb +179 -0
- data/lib/google/cloud/bigtable/rows_mutator.rb +113 -0
- data/lib/google/cloud/bigtable/rows_reader.rb +200 -0
- data/lib/google/cloud/bigtable/sample_row_key.rb +85 -0
- data/lib/google/cloud/bigtable/service.rb +913 -0
- data/lib/google/cloud/bigtable/status.rb +76 -0
- data/lib/google/cloud/bigtable/table.rb +686 -0
- data/lib/google/cloud/bigtable/table/cluster_state.rb +125 -0
- data/lib/google/cloud/bigtable/table/list.rb +154 -0
- data/lib/google/cloud/bigtable/table/restore_job.rb +117 -0
- data/lib/google/cloud/bigtable/v2.rb +146 -0
- data/lib/google/cloud/bigtable/v2/bigtable_client.rb +591 -0
- data/lib/google/cloud/bigtable/v2/bigtable_client_config.json +83 -0
- data/lib/google/cloud/bigtable/v2/credentials.rb +46 -0
- data/lib/google/cloud/bigtable/v2/doc/google/bigtable/v2/bigtable.rb +290 -0
- data/lib/google/cloud/bigtable/v2/doc/google/bigtable/v2/data.rb +493 -0
- data/lib/google/cloud/bigtable/v2/doc/google/protobuf/any.rb +131 -0
- data/lib/google/cloud/bigtable/v2/doc/google/protobuf/wrappers.rb +34 -0
- data/lib/google/cloud/bigtable/v2/doc/google/rpc/status.rb +39 -0
- data/lib/google/cloud/bigtable/value_range.rb +181 -0
- data/lib/google/cloud/bigtable/version.rb +22 -0
- metadata +337 -0
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# Copyright 2018 Google LLC
|
|
4
|
+
#
|
|
5
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
# you may not use this file except in compliance with the License.
|
|
7
|
+
# You may obtain a copy of the License at
|
|
8
|
+
#
|
|
9
|
+
# https://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
#
|
|
11
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
# See the License for the specific language governing permissions and
|
|
15
|
+
# limitations under the License.
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
module Google
|
|
19
|
+
module Cloud
|
|
20
|
+
module Bigtable
|
|
21
|
+
class Table
|
|
22
|
+
##
|
|
23
|
+
# Table::ClusterState is the state of a table's data in a particular cluster.
|
|
24
|
+
#
|
|
25
|
+
# @attr [String] cluster_name The name of the cluster.
|
|
26
|
+
class ClusterState
|
|
27
|
+
attr_reader :cluster_name
|
|
28
|
+
|
|
29
|
+
# @private
|
|
30
|
+
# Creates a new Table::ClusterState
|
|
31
|
+
#
|
|
32
|
+
def initialize grpc, cluster_name
|
|
33
|
+
@grpc = grpc
|
|
34
|
+
@cluster_name = cluster_name
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
##
|
|
38
|
+
# The state of replication for the table in this cluster.
|
|
39
|
+
# Valid values are:
|
|
40
|
+
# * `:INITIALIZING` - The cluster was recently created.
|
|
41
|
+
# * `:PLANNED_MAINTENANCE` - The table is temporarily unable to serve.
|
|
42
|
+
# * `:UNPLANNED_MAINTENANCE` - The table is temporarily unable to serve.
|
|
43
|
+
# * `:READY` - The table can serve.
|
|
44
|
+
# * `:READY_OPTIMIZING` - The table is fully created and ready for use
|
|
45
|
+
# after a restore, and is being optimized for performance. When
|
|
46
|
+
# optimizations are complete, the table will transition to `READY`
|
|
47
|
+
# state.
|
|
48
|
+
#
|
|
49
|
+
# @return [Symbol] The state of replication.
|
|
50
|
+
#
|
|
51
|
+
def replication_state
|
|
52
|
+
@grpc.replication_state
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
##
|
|
56
|
+
# The cluster was recently created, and the table must finish copying
|
|
57
|
+
# over pre-existing data from other clusters before it can begin
|
|
58
|
+
# receiving live replication updates and serving.
|
|
59
|
+
#
|
|
60
|
+
# @return [Boolean] `true` if the table in this cluster is initializing.
|
|
61
|
+
#
|
|
62
|
+
def initializing?
|
|
63
|
+
replication_state == :INITIALIZING
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
##
|
|
67
|
+
# The table is temporarily unable to serve
|
|
68
|
+
# requests from this cluster due to planned internal maintenance.
|
|
69
|
+
#
|
|
70
|
+
# @return [Boolean] `true` if the table in this cluster is in planned
|
|
71
|
+
# maintenance.
|
|
72
|
+
#
|
|
73
|
+
def planned_maintenance?
|
|
74
|
+
replication_state == :PLANNED_MAINTENANCE
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
##
|
|
78
|
+
# The table is temporarily unable to serve requests from this
|
|
79
|
+
# cluster due to unplanned or emergency maintenance.
|
|
80
|
+
#
|
|
81
|
+
# @return [Boolean] `true` if the table in this cluster is in unplanned
|
|
82
|
+
# maintenance.
|
|
83
|
+
#
|
|
84
|
+
def unplanned_maintenance?
|
|
85
|
+
replication_state == :UNPLANNED_MAINTENANCE
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
##
|
|
89
|
+
# The table can serve requests from this cluster.
|
|
90
|
+
# Depending on replication delay, reads may not immediately
|
|
91
|
+
# reflect the state of the table in other clusters.
|
|
92
|
+
#
|
|
93
|
+
# @return [Boolean] `true` if the table in this cluster is ready.
|
|
94
|
+
#
|
|
95
|
+
def ready?
|
|
96
|
+
replication_state == :READY
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
##
|
|
100
|
+
# The table is fully created and ready for use after a
|
|
101
|
+
# restore, and is being optimized for performance. When
|
|
102
|
+
# optimizations are complete, the table will transition to `READY`
|
|
103
|
+
# state.
|
|
104
|
+
#
|
|
105
|
+
# @return [Boolean] `true` if the table in this cluster is being
|
|
106
|
+
# optimized.
|
|
107
|
+
#
|
|
108
|
+
def ready_optimizing?
|
|
109
|
+
replication_state == :READY_OPTIMIZING
|
|
110
|
+
end
|
|
111
|
+
|
|
112
|
+
# @private
|
|
113
|
+
# New Table::ClusterState from a Google::Bigtable::Admin::V2::Table::ClusterState object.
|
|
114
|
+
# @param grpc [Google::Bigtable::Admin::V2::Table::ClusterState]
|
|
115
|
+
# @param cluster_name [String]
|
|
116
|
+
# @return [Google::Cloud::Bigtable::Table::ClusterState]
|
|
117
|
+
#
|
|
118
|
+
def self.from_grpc grpc, cluster_name
|
|
119
|
+
new grpc, cluster_name
|
|
120
|
+
end
|
|
121
|
+
end
|
|
122
|
+
end
|
|
123
|
+
end
|
|
124
|
+
end
|
|
125
|
+
end
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# Copyright 2018 Google LLC
|
|
4
|
+
#
|
|
5
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
# you may not use this file except in compliance with the License.
|
|
7
|
+
# You may obtain a copy of the License at
|
|
8
|
+
#
|
|
9
|
+
# https://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
#
|
|
11
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
# See the License for the specific language governing permissions and
|
|
15
|
+
# limitations under the License.
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
module Google
|
|
19
|
+
module Cloud
|
|
20
|
+
module Bigtable
|
|
21
|
+
class Table
|
|
22
|
+
##
|
|
23
|
+
# Table::List is a special-case array with additional
|
|
24
|
+
# values.
|
|
25
|
+
#
|
|
26
|
+
class List < DelegateClass(::Array)
|
|
27
|
+
# @private
|
|
28
|
+
# The gRPC Service object.
|
|
29
|
+
attr_accessor :service
|
|
30
|
+
|
|
31
|
+
# @private
|
|
32
|
+
# The gRPC page enumerable object.
|
|
33
|
+
attr_accessor :grpc
|
|
34
|
+
|
|
35
|
+
# @private
|
|
36
|
+
# Creates a new Table::List with an array of table instances.
|
|
37
|
+
def initialize arr = []
|
|
38
|
+
super arr
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
##
|
|
42
|
+
# Whether there is a next page of tables.
|
|
43
|
+
#
|
|
44
|
+
# @return [Boolean]
|
|
45
|
+
#
|
|
46
|
+
# @example
|
|
47
|
+
# require "google/cloud/bigtable"
|
|
48
|
+
#
|
|
49
|
+
# bigtable = Google::Cloud::Bigtable.new
|
|
50
|
+
#
|
|
51
|
+
# tables = bigtable.tables("my-instance")
|
|
52
|
+
# if tables.next?
|
|
53
|
+
# next_tables = tables.next
|
|
54
|
+
# end
|
|
55
|
+
#
|
|
56
|
+
def next?
|
|
57
|
+
grpc.next_page?
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
##
|
|
61
|
+
# Retrieves the next page of tables.
|
|
62
|
+
#
|
|
63
|
+
# @return [Table::List] The list of table instances.
|
|
64
|
+
#
|
|
65
|
+
# @example
|
|
66
|
+
# require "google/cloud/bigtable"
|
|
67
|
+
#
|
|
68
|
+
# bigtable = Google::Cloud::Bigtable.new
|
|
69
|
+
#
|
|
70
|
+
# tables = bigtable.tables("my-instance")
|
|
71
|
+
# if tables.next?
|
|
72
|
+
# next_tables = tables.next
|
|
73
|
+
# end
|
|
74
|
+
#
|
|
75
|
+
def next
|
|
76
|
+
ensure_grpc!
|
|
77
|
+
|
|
78
|
+
return nil unless next?
|
|
79
|
+
grpc.next_page
|
|
80
|
+
self.class.from_grpc grpc, service
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
##
|
|
84
|
+
# Retrieves remaining results by repeatedly invoking {#next} until
|
|
85
|
+
# {#next?} returns `false`. Calls the given block once for each
|
|
86
|
+
# result, which is passed as the argument to the block.
|
|
87
|
+
#
|
|
88
|
+
# An enumerator is returned if no block is given.
|
|
89
|
+
#
|
|
90
|
+
# This method will make repeated API calls until all remaining results
|
|
91
|
+
# are retrieved (unlike `#each`, for example, which merely iterates
|
|
92
|
+
# over the results returned by a single API call). Use with caution.
|
|
93
|
+
#
|
|
94
|
+
# @yield [table] The block for accessing each table instance.
|
|
95
|
+
# @yieldparam [Table] table The table instance object.
|
|
96
|
+
#
|
|
97
|
+
# @return [Enumerator,nil] An enumerator is returned if no block is given, otherwise `nil`.
|
|
98
|
+
#
|
|
99
|
+
# @example Iterating each table by passing a block:
|
|
100
|
+
# require "google/cloud/bigtable"
|
|
101
|
+
#
|
|
102
|
+
# bigtable = Google::Cloud::Bigtable.new
|
|
103
|
+
#
|
|
104
|
+
# bigtable.tables("my-instance").all do |table|
|
|
105
|
+
# puts table.table_id
|
|
106
|
+
# end
|
|
107
|
+
#
|
|
108
|
+
# @example Using the enumerator by not passing a block:
|
|
109
|
+
# require "google/cloud/bigtable"
|
|
110
|
+
#
|
|
111
|
+
# bigtable = Google::Cloud::Bigtable.new
|
|
112
|
+
#
|
|
113
|
+
# all_table_ids = bigtable.tables("my-instance").all.map do |table|
|
|
114
|
+
# puts table.table_id
|
|
115
|
+
# end
|
|
116
|
+
#
|
|
117
|
+
def all
|
|
118
|
+
return enum_for :all unless block_given?
|
|
119
|
+
|
|
120
|
+
results = self
|
|
121
|
+
loop do
|
|
122
|
+
results.each { |r| yield r }
|
|
123
|
+
break unless next?
|
|
124
|
+
grpc.next_page
|
|
125
|
+
results = self.class.from_grpc grpc, service
|
|
126
|
+
end
|
|
127
|
+
end
|
|
128
|
+
|
|
129
|
+
# @private
|
|
130
|
+
# New Table::List from a Google::Gax::PagedEnumerable<Google::Bigtable::Admin::V2::Table> object.
|
|
131
|
+
#
|
|
132
|
+
def self.from_grpc grpc, service
|
|
133
|
+
tables = List.new(Array(grpc.response.tables).map do |table|
|
|
134
|
+
Table.from_grpc table, service, view: :NAME_ONLY
|
|
135
|
+
end)
|
|
136
|
+
tables.grpc = grpc
|
|
137
|
+
tables.service = service
|
|
138
|
+
tables
|
|
139
|
+
end
|
|
140
|
+
|
|
141
|
+
protected
|
|
142
|
+
|
|
143
|
+
# @private
|
|
144
|
+
#
|
|
145
|
+
# Raises an error unless an active grpc call is available.
|
|
146
|
+
#
|
|
147
|
+
def ensure_grpc!
|
|
148
|
+
raise "Must have grpc call" unless grpc
|
|
149
|
+
end
|
|
150
|
+
end
|
|
151
|
+
end
|
|
152
|
+
end
|
|
153
|
+
end
|
|
154
|
+
end
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
# Copyright 2020 Google LLC
|
|
2
|
+
#
|
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
# you may not use this file except in compliance with the License.
|
|
5
|
+
# You may obtain a copy of the License at
|
|
6
|
+
#
|
|
7
|
+
# https://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
#
|
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
# See the License for the specific language governing permissions and
|
|
13
|
+
# limitations under the License.
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
module Google
|
|
17
|
+
module Cloud
|
|
18
|
+
module Bigtable
|
|
19
|
+
class Table
|
|
20
|
+
##
|
|
21
|
+
# # RestoreJob
|
|
22
|
+
#
|
|
23
|
+
# A resource representing the long-running, asynchronous processing of a backup restore operation. The
|
|
24
|
+
# job can be refreshed to retrieve the table object once the operation has been completed.
|
|
25
|
+
#
|
|
26
|
+
# See {Backup#restore}.
|
|
27
|
+
#
|
|
28
|
+
# @see https://cloud.google.com/bigtable/docs/reference/admin/rpc/google.longrunning#google.longrunning.Operation
|
|
29
|
+
# Long-running Operation
|
|
30
|
+
#
|
|
31
|
+
# @example
|
|
32
|
+
# require "google/cloud/bigtable"
|
|
33
|
+
#
|
|
34
|
+
# bigtable = Google::Cloud::Bigtable.new
|
|
35
|
+
# instance = bigtable.instance("my-instance")
|
|
36
|
+
# cluster = instance.cluster("my-cluster")
|
|
37
|
+
#
|
|
38
|
+
# backup = cluster.backup("my-backup")
|
|
39
|
+
#
|
|
40
|
+
# job = backup.restore("my-new-table")
|
|
41
|
+
#
|
|
42
|
+
# job.wait_until_done!
|
|
43
|
+
# job.done? #=> true
|
|
44
|
+
#
|
|
45
|
+
# if job.error?
|
|
46
|
+
# status = job.error
|
|
47
|
+
# else
|
|
48
|
+
# table = job.table
|
|
49
|
+
# optimized = job.optimize_table_operation_name
|
|
50
|
+
# end
|
|
51
|
+
#
|
|
52
|
+
class RestoreJob < LongrunningJob
|
|
53
|
+
##
|
|
54
|
+
# The optimize table operation name from operation metadata.
|
|
55
|
+
#
|
|
56
|
+
# @return [String, nil] The optimize table operation name, or `nil` if the optimize table operation is not
|
|
57
|
+
# complete.
|
|
58
|
+
#
|
|
59
|
+
# @example
|
|
60
|
+
# require "google/cloud/bigtable"
|
|
61
|
+
#
|
|
62
|
+
# bigtable = Google::Cloud::Bigtable.new
|
|
63
|
+
# instance = bigtable.instance("my-instance")
|
|
64
|
+
# cluster = instance.cluster("my-cluster")
|
|
65
|
+
#
|
|
66
|
+
# backup = cluster.backup("my-backup")
|
|
67
|
+
#
|
|
68
|
+
# job = backup.restore("my-new-table")
|
|
69
|
+
#
|
|
70
|
+
# job.wait_until_done!
|
|
71
|
+
# job.done? #=> true
|
|
72
|
+
#
|
|
73
|
+
# if job.error?
|
|
74
|
+
# status = job.error
|
|
75
|
+
# else
|
|
76
|
+
# table = job.table
|
|
77
|
+
# optimized = job.optimize_table_operation_name
|
|
78
|
+
# end
|
|
79
|
+
#
|
|
80
|
+
def optimize_table_operation_name
|
|
81
|
+
metadata.optimize_table_operation_name
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
##
|
|
85
|
+
# Gets the table object from operation results.
|
|
86
|
+
#
|
|
87
|
+
# @return [Google::Cloud::Bigtable::Table, nil] The table instance, or `nil` if the operation is not complete.
|
|
88
|
+
#
|
|
89
|
+
# @example
|
|
90
|
+
# require "google/cloud/bigtable"
|
|
91
|
+
#
|
|
92
|
+
# bigtable = Google::Cloud::Bigtable.new
|
|
93
|
+
# instance = bigtable.instance("my-instance")
|
|
94
|
+
# cluster = instance.cluster("my-cluster")
|
|
95
|
+
#
|
|
96
|
+
# backup = cluster.backup("my-backup")
|
|
97
|
+
#
|
|
98
|
+
# job = backup.restore("my-new-table")
|
|
99
|
+
#
|
|
100
|
+
# job.wait_until_done!
|
|
101
|
+
# job.done? #=> true
|
|
102
|
+
#
|
|
103
|
+
# if job.error?
|
|
104
|
+
# status = job.error
|
|
105
|
+
# else
|
|
106
|
+
# table = job.table
|
|
107
|
+
# optimized = job.optimize_table_operation_name
|
|
108
|
+
# end
|
|
109
|
+
#
|
|
110
|
+
def table
|
|
111
|
+
Table.from_grpc results, service if results
|
|
112
|
+
end
|
|
113
|
+
end
|
|
114
|
+
end
|
|
115
|
+
end
|
|
116
|
+
end
|
|
117
|
+
end
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
# Copyright 2020 Google LLC
|
|
2
|
+
#
|
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
# you may not use this file except in compliance with the License.
|
|
5
|
+
# You may obtain a copy of the License at
|
|
6
|
+
#
|
|
7
|
+
# https://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
#
|
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
# See the License for the specific language governing permissions and
|
|
13
|
+
# limitations under the License.
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
require "google/cloud/bigtable/v2/bigtable_client"
|
|
17
|
+
|
|
18
|
+
module Google
|
|
19
|
+
module Cloud
|
|
20
|
+
module Bigtable
|
|
21
|
+
# rubocop:disable LineLength
|
|
22
|
+
|
|
23
|
+
##
|
|
24
|
+
# # Ruby Client for Cloud Bigtable API
|
|
25
|
+
#
|
|
26
|
+
# [Cloud Bigtable API][Product Documentation]:
|
|
27
|
+
# API for reading and writing the contents of Bigtables associated with a
|
|
28
|
+
# cloud project.
|
|
29
|
+
# - [Product Documentation][]
|
|
30
|
+
#
|
|
31
|
+
# ## Quick Start
|
|
32
|
+
# In order to use this library, you first need to go through the following
|
|
33
|
+
# steps:
|
|
34
|
+
#
|
|
35
|
+
# 1. [Select or create a Cloud Platform project.](https://console.cloud.google.com/project)
|
|
36
|
+
# 2. [Enable billing for your project.](https://cloud.google.com/billing/docs/how-to/modify-project#enable_billing_for_a_project)
|
|
37
|
+
# 3. [Enable the Cloud Bigtable API.](https://console.cloud.google.com/apis/library/bigtable.googleapis.com)
|
|
38
|
+
# 4. [Setup Authentication.](https://googleapis.dev/ruby/google-cloud-bigtable/latest/file.AUTHENTICATION.html)
|
|
39
|
+
#
|
|
40
|
+
# ### Installation
|
|
41
|
+
# ```
|
|
42
|
+
# $ gem install google-cloud-bigtable
|
|
43
|
+
# ```
|
|
44
|
+
#
|
|
45
|
+
# ### Next Steps
|
|
46
|
+
# - Read the [Cloud Bigtable API Product documentation][Product Documentation]
|
|
47
|
+
# to learn more about the product and see How-to Guides.
|
|
48
|
+
# - View this [repository's main README](https://github.com/googleapis/google-cloud-ruby/blob/master/README.md)
|
|
49
|
+
# to see the full list of Cloud APIs that we cover.
|
|
50
|
+
#
|
|
51
|
+
# [Product Documentation]: https://cloud.google.com/bigtable
|
|
52
|
+
#
|
|
53
|
+
# ## Enabling Logging
|
|
54
|
+
#
|
|
55
|
+
# To enable logging for this library, set the logger for the underlying [gRPC](https://github.com/grpc/grpc/tree/master/src/ruby) library.
|
|
56
|
+
# The logger that you set may be a Ruby stdlib [`Logger`](https://ruby-doc.org/stdlib-2.5.0/libdoc/logger/rdoc/Logger.html) as shown below,
|
|
57
|
+
# or a [`Google::Cloud::Logging::Logger`](https://googleapis.dev/ruby/google-cloud-logging/latest)
|
|
58
|
+
# that will write logs to [Stackdriver Logging](https://cloud.google.com/logging/). See [grpc/logconfig.rb](https://github.com/grpc/grpc/blob/master/src/ruby/lib/grpc/logconfig.rb)
|
|
59
|
+
# and the gRPC [spec_helper.rb](https://github.com/grpc/grpc/blob/master/src/ruby/spec/spec_helper.rb) for additional information.
|
|
60
|
+
#
|
|
61
|
+
# Configuring a Ruby stdlib logger:
|
|
62
|
+
#
|
|
63
|
+
# ```ruby
|
|
64
|
+
# require "logger"
|
|
65
|
+
#
|
|
66
|
+
# module MyLogger
|
|
67
|
+
# LOGGER = Logger.new $stderr, level: Logger::WARN
|
|
68
|
+
# def logger
|
|
69
|
+
# LOGGER
|
|
70
|
+
# end
|
|
71
|
+
# end
|
|
72
|
+
#
|
|
73
|
+
# # Define a gRPC module-level logger method before grpc/logconfig.rb loads.
|
|
74
|
+
# module GRPC
|
|
75
|
+
# extend MyLogger
|
|
76
|
+
# end
|
|
77
|
+
# ```
|
|
78
|
+
#
|
|
79
|
+
module V2
|
|
80
|
+
# rubocop:enable LineLength
|
|
81
|
+
|
|
82
|
+
##
|
|
83
|
+
# Service for reading from and writing to existing Bigtable tables.
|
|
84
|
+
#
|
|
85
|
+
# @param credentials [Google::Auth::Credentials, String, Hash, GRPC::Core::Channel, GRPC::Core::ChannelCredentials, Proc]
|
|
86
|
+
# Provides the means for authenticating requests made by the client. This parameter can
|
|
87
|
+
# be many types.
|
|
88
|
+
# A `Google::Auth::Credentials` uses a the properties of its represented keyfile for
|
|
89
|
+
# authenticating requests made by this client.
|
|
90
|
+
# A `String` will be treated as the path to the keyfile to be used for the construction of
|
|
91
|
+
# credentials for this client.
|
|
92
|
+
# A `Hash` will be treated as the contents of a keyfile to be used for the construction of
|
|
93
|
+
# credentials for this client.
|
|
94
|
+
# A `GRPC::Core::Channel` will be used to make calls through.
|
|
95
|
+
# A `GRPC::Core::ChannelCredentials` for the setting up the RPC client. The channel credentials
|
|
96
|
+
# should already be composed with a `GRPC::Core::CallCredentials` object.
|
|
97
|
+
# A `Proc` will be used as an updater_proc for the Grpc channel. The proc transforms the
|
|
98
|
+
# metadata for requests, generally, to give OAuth credentials.
|
|
99
|
+
# @param scopes [Array<String>]
|
|
100
|
+
# The OAuth scopes for this service. This parameter is ignored if
|
|
101
|
+
# an updater_proc is supplied.
|
|
102
|
+
# @param client_config [Hash]
|
|
103
|
+
# A Hash for call options for each method. See
|
|
104
|
+
# Google::Gax#construct_settings for the structure of
|
|
105
|
+
# this data. Falls back to the default config if not specified
|
|
106
|
+
# or the specified config is missing data points.
|
|
107
|
+
# @param timeout [Numeric]
|
|
108
|
+
# The default timeout, in seconds, for calls made through this client.
|
|
109
|
+
# @param metadata [Hash]
|
|
110
|
+
# Default metadata to be sent with each request. This can be overridden on a per call basis.
|
|
111
|
+
# @param service_address [String]
|
|
112
|
+
# Override for the service hostname, or `nil` to leave as the default.
|
|
113
|
+
# @param service_port [Integer]
|
|
114
|
+
# Override for the service port, or `nil` to leave as the default.
|
|
115
|
+
# @param exception_transformer [Proc]
|
|
116
|
+
# An optional proc that intercepts any exceptions raised during an API call to inject
|
|
117
|
+
# custom error handling.
|
|
118
|
+
def self.new \
|
|
119
|
+
credentials: nil,
|
|
120
|
+
scopes: nil,
|
|
121
|
+
client_config: nil,
|
|
122
|
+
timeout: nil,
|
|
123
|
+
metadata: nil,
|
|
124
|
+
service_address: nil,
|
|
125
|
+
service_port: nil,
|
|
126
|
+
exception_transformer: nil,
|
|
127
|
+
lib_name: nil,
|
|
128
|
+
lib_version: nil
|
|
129
|
+
kwargs = {
|
|
130
|
+
credentials: credentials,
|
|
131
|
+
scopes: scopes,
|
|
132
|
+
client_config: client_config,
|
|
133
|
+
timeout: timeout,
|
|
134
|
+
metadata: metadata,
|
|
135
|
+
exception_transformer: exception_transformer,
|
|
136
|
+
lib_name: lib_name,
|
|
137
|
+
service_address: service_address,
|
|
138
|
+
service_port: service_port,
|
|
139
|
+
lib_version: lib_version
|
|
140
|
+
}.select { |_, v| v != nil }
|
|
141
|
+
Google::Cloud::Bigtable::V2::BigtableClient.new(**kwargs)
|
|
142
|
+
end
|
|
143
|
+
end
|
|
144
|
+
end
|
|
145
|
+
end
|
|
146
|
+
end
|