google-cloud-bigtable 1.2.1 → 2.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/AUTHENTICATION.md +1 -1
- data/CHANGELOG.md +57 -0
- data/TROUBLESHOOTING.md +2 -8
- data/lib/google-cloud-bigtable.rb +30 -27
- data/lib/google/cloud/bigtable.rb +18 -26
- data/lib/google/cloud/bigtable/app_profile.rb +3 -3
- data/lib/google/cloud/bigtable/app_profile/list.rb +6 -4
- data/lib/google/cloud/bigtable/backup.rb +445 -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 +1 -1
- data/lib/google/cloud/bigtable/cluster.rb +101 -2
- data/lib/google/cloud/bigtable/cluster/list.rb +2 -2
- data/lib/google/cloud/bigtable/column_family.rb +2 -2
- data/lib/google/cloud/bigtable/column_family_map.rb +11 -11
- data/lib/google/cloud/bigtable/column_range.rb +2 -2
- data/lib/google/cloud/bigtable/credentials.rb +36 -2
- data/lib/google/cloud/bigtable/gc_rule.rb +7 -7
- data/lib/google/cloud/bigtable/instance.rb +6 -6
- data/lib/google/cloud/bigtable/instance/cluster_map.rb +1 -1
- data/lib/google/cloud/bigtable/instance/list.rb +2 -2
- data/lib/google/cloud/bigtable/longrunning_job.rb +13 -2
- data/lib/google/cloud/bigtable/mutation_entry.rb +10 -9
- data/lib/google/cloud/bigtable/mutation_operations.rb +2 -2
- data/lib/google/cloud/bigtable/project.rb +1 -1
- data/lib/google/cloud/bigtable/read_modify_write_rule.rb +2 -2
- data/lib/google/cloud/bigtable/read_operations.rb +2 -2
- data/lib/google/cloud/bigtable/routing_policy.rb +2 -2
- data/lib/google/cloud/bigtable/row_filter/chain_filter.rb +3 -3
- data/lib/google/cloud/bigtable/row_filter/condition_filter.rb +3 -3
- data/lib/google/cloud/bigtable/row_filter/interleave_filter.rb +3 -3
- data/lib/google/cloud/bigtable/row_filter/simple_filter.rb +3 -3
- data/lib/google/cloud/bigtable/row_range.rb +2 -2
- data/lib/google/cloud/bigtable/rows_mutator.rb +3 -3
- data/lib/google/cloud/bigtable/rows_reader.rb +10 -10
- data/lib/google/cloud/bigtable/sample_row_key.rb +2 -2
- data/lib/google/cloud/bigtable/service.rb +282 -245
- data/lib/google/cloud/bigtable/table.rb +5 -4
- data/lib/google/cloud/bigtable/table/cluster_state.rb +27 -6
- data/lib/google/cloud/bigtable/table/list.rb +2 -2
- data/lib/google/cloud/bigtable/table/restore_job.rb +117 -0
- data/lib/google/cloud/bigtable/value_range.rb +2 -2
- data/lib/google/cloud/bigtable/version.rb +1 -1
- metadata +16 -94
- data/lib/google/bigtable/admin/v2/bigtable_instance_admin_pb.rb +0 -145
- data/lib/google/bigtable/admin/v2/bigtable_instance_admin_services_pb.rb +0 -90
- data/lib/google/bigtable/admin/v2/bigtable_table_admin_pb.rb +0 -208
- data/lib/google/bigtable/admin/v2/bigtable_table_admin_services_pb.rb +0 -154
- data/lib/google/bigtable/admin/v2/common_pb.rb +0 -30
- data/lib/google/bigtable/admin/v2/instance_pb.rb +0 -74
- data/lib/google/bigtable/admin/v2/table_pb.rb +0 -127
- data/lib/google/bigtable/v2/bigtable_pb.rb +0 -113
- data/lib/google/bigtable/v2/bigtable_services_pb.rb +0 -68
- data/lib/google/bigtable/v2/data_pb.rb +0 -156
- data/lib/google/cloud/bigtable/admin.rb +0 -202
- data/lib/google/cloud/bigtable/admin/credentials.rb +0 -27
- data/lib/google/cloud/bigtable/admin/v2.rb +0 -223
- data/lib/google/cloud/bigtable/admin/v2/bigtable_instance_admin_client.rb +0 -1451
- data/lib/google/cloud/bigtable/admin/v2/bigtable_instance_admin_client_config.json +0 -139
- data/lib/google/cloud/bigtable/admin/v2/bigtable_table_admin_client.rb +0 -1734
- data/lib/google/cloud/bigtable/admin/v2/bigtable_table_admin_client_config.json +0 -163
- data/lib/google/cloud/bigtable/admin/v2/credentials.rb +0 -51
- data/lib/google/cloud/bigtable/admin/v2/doc/google/bigtable/admin/v2/bigtable_instance_admin.rb +0 -297
- data/lib/google/cloud/bigtable/admin/v2/doc/google/bigtable/admin/v2/bigtable_table_admin.rb +0 -587
- data/lib/google/cloud/bigtable/admin/v2/doc/google/bigtable/admin/v2/instance.rb +0 -193
- data/lib/google/cloud/bigtable/admin/v2/doc/google/bigtable/admin/v2/table.rb +0 -303
- data/lib/google/cloud/bigtable/admin/v2/doc/google/iam/v1/iam_policy.rb +0 -64
- data/lib/google/cloud/bigtable/admin/v2/doc/google/iam/v1/options.rb +0 -33
- data/lib/google/cloud/bigtable/admin/v2/doc/google/iam/v1/policy.rb +0 -151
- data/lib/google/cloud/bigtable/admin/v2/doc/google/longrunning/operations.rb +0 -51
- data/lib/google/cloud/bigtable/admin/v2/doc/google/protobuf/any.rb +0 -131
- data/lib/google/cloud/bigtable/admin/v2/doc/google/protobuf/duration.rb +0 -91
- data/lib/google/cloud/bigtable/admin/v2/doc/google/protobuf/empty.rb +0 -29
- data/lib/google/cloud/bigtable/admin/v2/doc/google/protobuf/field_mask.rb +0 -222
- data/lib/google/cloud/bigtable/admin/v2/doc/google/protobuf/timestamp.rb +0 -113
- data/lib/google/cloud/bigtable/admin/v2/doc/google/rpc/status.rb +0 -39
- data/lib/google/cloud/bigtable/admin/v2/doc/google/type/expr.rb +0 -45
- data/lib/google/cloud/bigtable/v2.rb +0 -146
- data/lib/google/cloud/bigtable/v2/bigtable_client.rb +0 -591
- data/lib/google/cloud/bigtable/v2/bigtable_client_config.json +0 -83
- data/lib/google/cloud/bigtable/v2/credentials.rb +0 -46
- data/lib/google/cloud/bigtable/v2/doc/google/bigtable/v2/bigtable.rb +0 -290
- data/lib/google/cloud/bigtable/v2/doc/google/bigtable/v2/data.rb +0 -493
- data/lib/google/cloud/bigtable/v2/doc/google/protobuf/any.rb +0 -131
- data/lib/google/cloud/bigtable/v2/doc/google/protobuf/wrappers.rb +0 -34
- data/lib/google/cloud/bigtable/v2/doc/google/rpc/status.rb +0 -39
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 864b31028834907aa872f0f5aec7a31a682e419c286744c1cc3243072597e739
|
4
|
+
data.tar.gz: 543de2a38416692f95400157b4ca67520b5a6765bed60dd1237b3be405a10d2e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a62102b9792b017c396477aa79435a29b1c495e2234c8a34c6040c74883c9aaa7f07cf9e945606a139e7f8d032f57663da235a8a6f3e8922eeaad72f5a582b46
|
7
|
+
data.tar.gz: 5d474fd9b72cb0d2474be964d1c0af670266f577af221d6ae76256c34f935ec239040b824e2eadd7e391ad09fde511406f210f0e007796cea69e163d244827f9
|
data/AUTHENTICATION.md
CHANGED
@@ -76,7 +76,7 @@ The environment variables that google-cloud-bigtable checks for project ID are:
|
|
76
76
|
1. `BIGTABLE_PROJECT`
|
77
77
|
2. `GOOGLE_CLOUD_PROJECT`
|
78
78
|
|
79
|
-
The environment variables that google-cloud-bigtable checks for credentials are configured on {Google::Cloud::Bigtable::
|
79
|
+
The environment variables that google-cloud-bigtable checks for credentials are configured on {Google::Cloud::Bigtable::Credentials}:
|
80
80
|
|
81
81
|
1. `BIGTABLE_CREDENTIALS` - Path to JSON file, or JSON contents
|
82
82
|
2. `BIGTABLE_KEYFILE` - Path to JSON file, or JSON contents
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,62 @@
|
|
1
1
|
# Release History
|
2
2
|
|
3
|
+
### 2.2.0 / 2020-11-11
|
4
|
+
|
5
|
+
#### Features
|
6
|
+
|
7
|
+
* Add Backup-level IAM Policy support
|
8
|
+
* Add Backup#policy
|
9
|
+
* Add Backup#update_policy
|
10
|
+
* Add Backup#test_iam_permissions
|
11
|
+
|
12
|
+
### 2.1.0 / 2020-09-17
|
13
|
+
|
14
|
+
#### Features
|
15
|
+
|
16
|
+
* quota_project can be set via library configuration ([#7630](https://www.github.com/googleapis/google-cloud-ruby/issues/7630))
|
17
|
+
|
18
|
+
### 2.0.0 / 2020-08-06
|
19
|
+
|
20
|
+
This is a major update that removes the "low-level" client interface code, and
|
21
|
+
instead adds the new `google-cloud-bigtable-v2` and
|
22
|
+
`google-cloud-bigtable-admin-v2` gems as dependencies. The new dependencies
|
23
|
+
are rewritten low-level clients, produced by a next-generation client code
|
24
|
+
generator, with improved performance and stability.
|
25
|
+
|
26
|
+
This change should have no effect on the high-level interface that most users
|
27
|
+
will use. The one exception is that the (mostly undocumented) `client_config`
|
28
|
+
argument, for adjusting low-level parameters such as RPC retry settings on
|
29
|
+
client objects, has been removed. If you need to adjust these parameters, use
|
30
|
+
the configuration interface in `google-cloud-bigtable-v2` and
|
31
|
+
`google-cloud-bigtable-admin-v2`.
|
32
|
+
|
33
|
+
Substantial changes have been made in the low-level interfaces, however. If you
|
34
|
+
are using the low-level classes under the `Google::Cloud::Bigtable::V2` or
|
35
|
+
`Google::Cloud::Bigtable::Admin::V2` modules, please review the docs for the
|
36
|
+
new `google-cloud-bigtable-v2` and `google-cloud-bigtable-admin-v2` gems.
|
37
|
+
In particular:
|
38
|
+
|
39
|
+
* Some classes have been renamed, notably the client classes themselves.
|
40
|
+
* The client constructor takes a configuration block instead of configuration
|
41
|
+
keyword arguments.
|
42
|
+
* All RPC method arguments are now keyword arguments.
|
43
|
+
|
44
|
+
### 1.3.0 / 2020-07-21
|
45
|
+
|
46
|
+
#### Features
|
47
|
+
|
48
|
+
* Add Managed Backups
|
49
|
+
* Add Cluster#create_backup, Cluster#backup and Cluster#backups
|
50
|
+
* Add Backup, Backup::Job and Backup::List
|
51
|
+
* Add Table::RestoreJob
|
52
|
+
* Add ClusterState#ready_optimizing?
|
53
|
+
|
54
|
+
### 1.2.2 / 2020-05-28
|
55
|
+
|
56
|
+
#### Documentation
|
57
|
+
|
58
|
+
* Fix a few broken links
|
59
|
+
|
3
60
|
### 1.2.1 / 2020-05-21
|
4
61
|
|
5
62
|
#### Bug Fixes
|
data/TROUBLESHOOTING.md
CHANGED
@@ -24,14 +24,8 @@ improved, *please* create a new issue on GitHub so we can talk about it.
|
|
24
24
|
|
25
25
|
- [New issue][gh-ruby]
|
26
26
|
|
27
|
-
Or, you can ask questions on the [Google Cloud Platform Slack][slack-ruby]. You
|
28
|
-
can use the "ruby" channel for general Ruby questions, or use the
|
29
|
-
"google-cloud-ruby" channel if you have questions about this gem in particular.
|
30
|
-
|
31
27
|
[so-ruby]: http://stackoverflow.com/questions/tagged/google-cloud-platform+ruby+bigtable
|
32
28
|
|
33
|
-
[gh-search-ruby]: https://github.com/
|
34
|
-
|
35
|
-
[gh-ruby]: https://github.com/googlecloudplatform/google-cloud-ruby/issues/new
|
29
|
+
[gh-search-ruby]: https://github.com/googleapis/google-cloud-ruby/issues?q=label%3A%22api%3A+bigtable%22
|
36
30
|
|
37
|
-
[
|
31
|
+
[gh-ruby]: https://github.com/googleapis/google-cloud-ruby/issues/new
|
@@ -55,11 +55,6 @@ module Google
|
|
55
55
|
# should already be composed with a `GRPC::Core::CallCredentials` object.
|
56
56
|
# `Proc` will be used as an updater_proc for the gRPC channel. The proc transforms the
|
57
57
|
# metadata for requests, generally, to give OAuth credentials.
|
58
|
-
# @param client_config [Hash]
|
59
|
-
# A hash for call options for each method.
|
60
|
-
# See Google::Gax#construct_settings for the structure of
|
61
|
-
# this data. Falls back to the default config if not specified
|
62
|
-
# or the specified config is missing data points.
|
63
58
|
# @return [Google::Cloud::Bigtable::Project]
|
64
59
|
#
|
65
60
|
# @example
|
@@ -69,13 +64,12 @@ module Google
|
|
69
64
|
#
|
70
65
|
# bigtable = gcloud.bigtable
|
71
66
|
#
|
72
|
-
def bigtable scope: nil, timeout: nil, credentials: nil
|
67
|
+
def bigtable scope: nil, timeout: nil, credentials: nil
|
73
68
|
Google::Cloud.bigtable(
|
74
|
-
project_id:
|
75
|
-
credentials:
|
76
|
-
scope:
|
77
|
-
timeout:
|
78
|
-
client_config: client_config
|
69
|
+
project_id: @project,
|
70
|
+
credentials: (credentials || @keyfile),
|
71
|
+
scope: scope,
|
72
|
+
timeout: (timeout || @timeout)
|
79
73
|
)
|
80
74
|
end
|
81
75
|
|
@@ -110,11 +104,6 @@ module Google
|
|
110
104
|
# updater_proc is supplied.
|
111
105
|
# @param timeout [Integer]
|
112
106
|
# The default timeout, in seconds, for calls made through this client.
|
113
|
-
# @param client_config [Hash]
|
114
|
-
# A hash for call options for each method.
|
115
|
-
# See Google::Gax#construct_settings for the structure of
|
116
|
-
# this data. Falls back to the default config if not specified
|
117
|
-
# or the specified config is missing data points. Optional.
|
118
107
|
# @return [Google::Cloud::Bigtable::Project]
|
119
108
|
#
|
120
109
|
# @example
|
@@ -122,14 +111,13 @@ module Google
|
|
122
111
|
#
|
123
112
|
# bigtable = Google::Cloud.bigtable
|
124
113
|
#
|
125
|
-
def self.bigtable project_id: nil, credentials: nil, scope: nil, timeout: nil
|
114
|
+
def self.bigtable project_id: nil, credentials: nil, scope: nil, timeout: nil
|
126
115
|
require "google/cloud/bigtable"
|
127
116
|
Google::Cloud::Bigtable.new(
|
128
|
-
project_id:
|
129
|
-
credentials:
|
130
|
-
scope:
|
131
|
-
timeout:
|
132
|
-
client_config: client_config
|
117
|
+
project_id: project_id,
|
118
|
+
credentials: credentials,
|
119
|
+
scope: scope,
|
120
|
+
timeout: timeout
|
133
121
|
)
|
134
122
|
end
|
135
123
|
end
|
@@ -149,6 +137,21 @@ Google::Cloud.configure.add_config! :bigtable do |config|
|
|
149
137
|
default_emulator = Google::Cloud::Config.deferred do
|
150
138
|
ENV["BIGTABLE_EMULATOR_HOST"]
|
151
139
|
end
|
140
|
+
default_scopes = [
|
141
|
+
"https://www.googleapis.com/auth/bigtable.admin",
|
142
|
+
"https://www.googleapis.com/auth/bigtable.admin.cluster",
|
143
|
+
"https://www.googleapis.com/auth/bigtable.admin.instance",
|
144
|
+
"https://www.googleapis.com/auth/bigtable.admin.table",
|
145
|
+
"https://www.googleapis.com/auth/bigtable.data",
|
146
|
+
"https://www.googleapis.com/auth/bigtable.data.readonly",
|
147
|
+
"https://www.googleapis.com/auth/cloud-bigtable.admin",
|
148
|
+
"https://www.googleapis.com/auth/cloud-bigtable.admin.cluster",
|
149
|
+
"https://www.googleapis.com/auth/cloud-bigtable.admin.table",
|
150
|
+
"https://www.googleapis.com/auth/cloud-bigtable.data",
|
151
|
+
"https://www.googleapis.com/auth/cloud-bigtable.data.readonly",
|
152
|
+
"https://www.googleapis.com/auth/cloud-platform",
|
153
|
+
"https://www.googleapis.com/auth/cloud-platform.read-only"
|
154
|
+
]
|
152
155
|
|
153
156
|
config.add_field! :project_id, default_project, match: String, allow_nil: true
|
154
157
|
config.add_alias! :project, :project_id
|
@@ -162,10 +165,10 @@ Google::Cloud.configure.add_config! :bigtable do |config|
|
|
162
165
|
Proc
|
163
166
|
],
|
164
167
|
allow_nil: true
|
165
|
-
config.add_field! :scope,
|
168
|
+
config.add_field! :scope, default_scopes, match: [String, Array]
|
169
|
+
config.add_field! :quota_project, nil, match: String
|
166
170
|
config.add_field! :timeout, nil, match: Integer
|
167
|
-
config.add_field! :
|
168
|
-
config.add_field! :
|
169
|
-
|
170
|
-
config.add_field! :endpoint, nil, match: String
|
171
|
+
config.add_field! :emulator_host, default_emulator, match: String, allow_nil: true
|
172
|
+
config.add_field! :endpoint, "bigtable.googleapis.com", match: String
|
173
|
+
config.add_field! :endpoint_admin, "bigtableadmin.googleapis.com", match: String
|
171
174
|
end
|
@@ -51,6 +51,8 @@ module Google
|
|
51
51
|
# metadata for requests, generally, to give OAuth credentials.
|
52
52
|
# @param [String] endpoint Override of the endpoint host name. Optional.
|
53
53
|
# If the param is nil, uses the default endpoint.
|
54
|
+
# @param [String] endpoint_admin Override of the admin service endpoint host name. Optional.
|
55
|
+
# If the param is nil, uses the default admin endpoint.
|
54
56
|
# @param [String] emulator_host Bigtable emulator host. Optional.
|
55
57
|
# If the parameter is nil, uses the value of the `emulator_host` config.
|
56
58
|
# @param scope [Array<String>]
|
@@ -59,11 +61,6 @@ module Google
|
|
59
61
|
# APIs](https://developers.google.com/identity/protocols/OAuth2).
|
60
62
|
# The OAuth scopes for this service. This parameter is ignored if an
|
61
63
|
# updater_proc is supplied.
|
62
|
-
# @param client_config [Hash]
|
63
|
-
# A hash for call options for each method.
|
64
|
-
# See Google::Gax#construct_settings for the structure of
|
65
|
-
# this data. Falls back to the default config if not specified
|
66
|
-
# or the specified config is missing data points.
|
67
64
|
# @param timeout [Integer]
|
68
65
|
# The default timeout, in seconds, for calls made through this client. Optional.
|
69
66
|
# @return [Google::Cloud::Bigtable::Project]
|
@@ -73,28 +70,28 @@ module Google
|
|
73
70
|
#
|
74
71
|
# client = Google::Cloud::Bigtable.new
|
75
72
|
#
|
76
|
-
def self.new project_id: nil,
|
73
|
+
def self.new project_id: nil,
|
74
|
+
credentials: nil,
|
75
|
+
emulator_host: nil,
|
76
|
+
scope: nil,
|
77
|
+
endpoint: nil,
|
78
|
+
endpoint_admin: nil,
|
77
79
|
timeout: nil
|
78
80
|
project_id ||= default_project_id
|
79
81
|
scope ||= configure.scope
|
80
82
|
timeout ||= configure.timeout
|
81
|
-
client_config ||= configure.client_config
|
82
83
|
emulator_host ||= configure.emulator_host
|
83
84
|
endpoint ||= configure.endpoint
|
85
|
+
endpoint_admin ||= configure.endpoint_admin
|
84
86
|
|
85
|
-
if emulator_host
|
86
|
-
return new_with_emulator project_id, emulator_host, timeout,
|
87
|
-
client_config
|
88
|
-
end
|
87
|
+
return new_with_emulator project_id, emulator_host, timeout if emulator_host
|
89
88
|
|
90
89
|
credentials = resolve_credentials credentials, scope
|
91
90
|
project_id = resolve_project_id project_id, credentials
|
92
91
|
raise ArgumentError, "project_id is missing" if project_id.empty?
|
93
92
|
|
94
|
-
service = Bigtable::Service.new
|
95
|
-
project_id, credentials,
|
96
|
-
host: endpoint, timeout: timeout, client_config: client_config
|
97
|
-
)
|
93
|
+
service = Bigtable::Service.new \
|
94
|
+
project_id, credentials, host: endpoint, host_admin: endpoint_admin, timeout: timeout
|
98
95
|
Bigtable::Project.new service
|
99
96
|
end
|
100
97
|
|
@@ -113,10 +110,10 @@ module Google
|
|
113
110
|
# * `scope` - (String, Array<String>) The OAuth 2.0 scopes controlling
|
114
111
|
# the set of resources and operations that the connection can access.
|
115
112
|
# * `timeout` - (Integer) Default timeout to use in requests.
|
116
|
-
# * `client_config` - (Hash) A hash of values to override the default
|
117
|
-
# behavior of the API client.
|
118
113
|
# * `endpoint` - (String) Override of the endpoint host name, or `nil`
|
119
114
|
# to use the default endpoint.
|
115
|
+
# * `endpoint_admin` - (String) Override of the admin service endpoint
|
116
|
+
# host name, or `nil` to use the default admin endpoint.
|
120
117
|
#
|
121
118
|
# @return [Google::Cloud::Config] The configuration object the
|
122
119
|
# Google::Cloud::Bigtable library uses.
|
@@ -130,18 +127,13 @@ module Google
|
|
130
127
|
# @private
|
131
128
|
# New client given an emulator host.
|
132
129
|
#
|
133
|
-
def self.new_with_emulator project_id, emulator_host, timeout
|
134
|
-
client_config
|
130
|
+
def self.new_with_emulator project_id, emulator_host, timeout
|
135
131
|
project_id = project_id.to_s # Always cast to a string
|
136
132
|
raise ArgumentError, "project_id is missing" if project_id.empty?
|
137
133
|
|
138
|
-
Bigtable::
|
139
|
-
|
140
|
-
|
141
|
-
host: emulator_host, timeout: timeout,
|
142
|
-
client_config: client_config
|
143
|
-
)
|
144
|
-
)
|
134
|
+
service = Bigtable::Service.new \
|
135
|
+
project_id, :this_channel_is_insecure, host: emulator_host, host_admin: emulator_host, timeout: timeout
|
136
|
+
Bigtable::Project.new service
|
145
137
|
end
|
146
138
|
|
147
139
|
# @private
|
@@ -193,7 +193,7 @@ module Google
|
|
193
193
|
#
|
194
194
|
def routing_policy= policy
|
195
195
|
routing_policy_grpc = policy.to_grpc
|
196
|
-
if routing_policy_grpc.is_a? Google::Bigtable::Admin::V2::AppProfile::SingleClusterRouting
|
196
|
+
if routing_policy_grpc.is_a? Google::Cloud::Bigtable::Admin::V2::AppProfile::SingleClusterRouting
|
197
197
|
@grpc.single_cluster_routing = routing_policy_grpc
|
198
198
|
@changed_fields["routing_policy"] = "single_cluster_routing"
|
199
199
|
else
|
@@ -417,8 +417,8 @@ module Google
|
|
417
417
|
# @private
|
418
418
|
#
|
419
419
|
# Creates a new Instance instance from a
|
420
|
-
# Google::Bigtable::Admin::V2::Table.
|
421
|
-
# @param grpc [Google::Bigtable::Admin::V2::Table]
|
420
|
+
# Google::Cloud::Bigtable::Admin::V2::Table.
|
421
|
+
# @param grpc [Google::Cloud::Bigtable::Admin::V2::Table]
|
422
422
|
# @param service [Google::Cloud::Bigtable::Service]
|
423
423
|
# @return [Google::Cloud::Bigtable::Table]
|
424
424
|
def self.from_grpc grpc, service
|
@@ -97,7 +97,7 @@ module Google
|
|
97
97
|
# @yield [app_profile] The block for accessing each app profile.
|
98
98
|
# @yieldparam [AppProfile] app_profile The app profile object.
|
99
99
|
#
|
100
|
-
# @return [Enumerator]
|
100
|
+
# @return [Enumerator,nil] An enumerator is returned if no block is given, otherwise `nil`.
|
101
101
|
#
|
102
102
|
# @example Iterating each app profile by passing a block:
|
103
103
|
# require "google/cloud/bigtable"
|
@@ -118,7 +118,7 @@ module Google
|
|
118
118
|
#
|
119
119
|
# instance = bigtable.instance("my-instance")
|
120
120
|
#
|
121
|
-
#
|
121
|
+
# all_app_profile_ids = instance.app_profiles.all.map do |app_profile|
|
122
122
|
# app_profile.name
|
123
123
|
# end
|
124
124
|
#
|
@@ -135,8 +135,10 @@ module Google
|
|
135
135
|
end
|
136
136
|
|
137
137
|
# @private
|
138
|
-
# New Snapshot::List from a
|
139
|
-
#
|
138
|
+
# New Snapshot::List from a Gapic::PagedEnumerable<Google::Cloud::Bigtable::Admin::V2::AppProfile>
|
139
|
+
# object.
|
140
|
+
#
|
141
|
+
# @param grpc [Gapic::PagedEnumerable<Google::Cloud::Bigtable::Admin::V2::AppProfile> ]
|
140
142
|
# @param service [Google::Cloud::Bigtable::Service]
|
141
143
|
# @return [Array<Google::Cloud::Bigtable::AppProfile>]
|
142
144
|
def self.from_grpc grpc, service
|
@@ -0,0 +1,445 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Copyright 2020 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
|
+
require "google/cloud/bigtable/backup/job"
|
19
|
+
require "google/cloud/bigtable/backup/list"
|
20
|
+
require "google/cloud/bigtable/convert"
|
21
|
+
require "google/cloud/bigtable/policy"
|
22
|
+
require "google/cloud/bigtable/table/restore_job"
|
23
|
+
|
24
|
+
|
25
|
+
module Google
|
26
|
+
module Cloud
|
27
|
+
module Bigtable
|
28
|
+
##
|
29
|
+
# # Backup
|
30
|
+
#
|
31
|
+
# A backup of a Cloud Bigtable table. See {Cluster#create_backup}, {Cluster#backup} and {Cluster#backups}.
|
32
|
+
#
|
33
|
+
# @example
|
34
|
+
# require "google/cloud/bigtable"
|
35
|
+
#
|
36
|
+
# bigtable = Google::Cloud::Bigtable.new
|
37
|
+
# instance = bigtable.instance("my-instance")
|
38
|
+
# cluster = instance.cluster("my-cluster")
|
39
|
+
#
|
40
|
+
# backup = cluster.backup("my-backup")
|
41
|
+
#
|
42
|
+
# # Update
|
43
|
+
# backup.expire_time = Time.now + 60 * 60 * 7
|
44
|
+
# backup.save
|
45
|
+
#
|
46
|
+
# # Delete
|
47
|
+
# backup.delete
|
48
|
+
#
|
49
|
+
class Backup
|
50
|
+
# @private
|
51
|
+
# The gRPC Service object.
|
52
|
+
attr_accessor :service
|
53
|
+
|
54
|
+
##
|
55
|
+
# @private A list of attributes that were updated.
|
56
|
+
attr_reader :updates
|
57
|
+
|
58
|
+
# @private
|
59
|
+
#
|
60
|
+
# Creates a new Backup instance.
|
61
|
+
def initialize grpc, service
|
62
|
+
@grpc = grpc
|
63
|
+
@service = service
|
64
|
+
end
|
65
|
+
|
66
|
+
##
|
67
|
+
# The unique identifier for the project to which the backup belongs.
|
68
|
+
#
|
69
|
+
# @return [String]
|
70
|
+
#
|
71
|
+
def project_id
|
72
|
+
@grpc.name.split("/")[1]
|
73
|
+
end
|
74
|
+
|
75
|
+
##
|
76
|
+
# The unique identifier for the instance to which the backup belongs.
|
77
|
+
#
|
78
|
+
# @return [String]
|
79
|
+
#
|
80
|
+
def instance_id
|
81
|
+
@grpc.name.split("/")[3]
|
82
|
+
end
|
83
|
+
|
84
|
+
##
|
85
|
+
# The unique identifier for the cluster to which the backup belongs.
|
86
|
+
#
|
87
|
+
# @return [String]
|
88
|
+
#
|
89
|
+
def cluster_id
|
90
|
+
@grpc.name.split("/")[5]
|
91
|
+
end
|
92
|
+
|
93
|
+
##
|
94
|
+
# The unique identifier for the backup.
|
95
|
+
#
|
96
|
+
# @return [String]
|
97
|
+
#
|
98
|
+
def backup_id
|
99
|
+
@grpc.name.split("/")[7]
|
100
|
+
end
|
101
|
+
|
102
|
+
##
|
103
|
+
# The unique name of the backup. Value in the form
|
104
|
+
# `projects/<project>/instances/<instance>/clusters/<cluster>/backups/<backup>`.
|
105
|
+
#
|
106
|
+
# @return [String]
|
107
|
+
#
|
108
|
+
def path
|
109
|
+
@grpc.name
|
110
|
+
end
|
111
|
+
|
112
|
+
##
|
113
|
+
# The table from which this backup was created.
|
114
|
+
#
|
115
|
+
# @param perform_lookup [Boolean] Creates table object without verifying that the table resource exists. Calls
|
116
|
+
# made on this object will raise errors if the table does not exist. Default value is `false`. Optional. Helps
|
117
|
+
# to reduce admin API calls.
|
118
|
+
# @param view [Symbol] Table view type. Default view type is `:SCHEMA_VIEW`. Valid view types are:
|
119
|
+
#
|
120
|
+
# * `:NAME_ONLY` - Only populates `name`.
|
121
|
+
# * `:SCHEMA_VIEW` - Only populates `name` and fields related to the table's schema.
|
122
|
+
# * `:REPLICATION_VIEW` - Only populates `name` and fields related to the table's replication state.
|
123
|
+
# * `:FULL` - Populates all fields.
|
124
|
+
#
|
125
|
+
# @return [Table]
|
126
|
+
#
|
127
|
+
def source_table perform_lookup: nil, view: nil
|
128
|
+
table = Table.from_path @grpc.source_table, service
|
129
|
+
return table.reload! view: view if perform_lookup
|
130
|
+
table
|
131
|
+
end
|
132
|
+
|
133
|
+
##
|
134
|
+
# The expiration time of the backup, with microseconds granularity that must be at least 6 hours and at most 30
|
135
|
+
# days from the time the request is received. Once the expire time has passed, Cloud Bigtable will delete the
|
136
|
+
# backup and free the resources used by the backup.
|
137
|
+
#
|
138
|
+
# @return [Time]
|
139
|
+
#
|
140
|
+
def expire_time
|
141
|
+
Convert.timestamp_to_time @grpc.expire_time
|
142
|
+
end
|
143
|
+
|
144
|
+
##
|
145
|
+
# Sets the expiration time of the backup, with microseconds granularity that must be at least 6 hours and at
|
146
|
+
# most 30 days from the time the request is received. Once the {#expire_time} has passed, Cloud Bigtable will
|
147
|
+
# delete the backup and free the resources used by the backup.
|
148
|
+
#
|
149
|
+
# @param [Time] new_expire_time The new expiration time of the backup.
|
150
|
+
#
|
151
|
+
def expire_time= new_expire_time
|
152
|
+
@grpc.expire_time = Convert.time_to_timestamp new_expire_time
|
153
|
+
end
|
154
|
+
|
155
|
+
##
|
156
|
+
# The time that the backup was started (i.e. approximately the time the `CreateBackup` request is received). The
|
157
|
+
# row data in this backup will be no older than this timestamp.
|
158
|
+
#
|
159
|
+
# @return [Time]
|
160
|
+
#
|
161
|
+
def start_time
|
162
|
+
Convert.timestamp_to_time @grpc.start_time
|
163
|
+
end
|
164
|
+
|
165
|
+
##
|
166
|
+
# The time that the backup was finished. The row data in the backup will be no newer than this timestamp.
|
167
|
+
#
|
168
|
+
# @return [Time]
|
169
|
+
#
|
170
|
+
def end_time
|
171
|
+
Convert.timestamp_to_time @grpc.end_time
|
172
|
+
end
|
173
|
+
|
174
|
+
##
|
175
|
+
# The size of the backup in bytes.
|
176
|
+
#
|
177
|
+
# @return [Integer]
|
178
|
+
#
|
179
|
+
def size_bytes
|
180
|
+
@grpc.size_bytes
|
181
|
+
end
|
182
|
+
|
183
|
+
##
|
184
|
+
# The current state of the backup. Possible values are `:CREATING` and `:READY`.
|
185
|
+
#
|
186
|
+
# @return [Symbol]
|
187
|
+
#
|
188
|
+
def state
|
189
|
+
@grpc.state
|
190
|
+
end
|
191
|
+
|
192
|
+
##
|
193
|
+
# The backup is currently being created, and may be destroyed if the creation process encounters an error.
|
194
|
+
#
|
195
|
+
# @return [Boolean]
|
196
|
+
#
|
197
|
+
def creating?
|
198
|
+
state == :CREATING
|
199
|
+
end
|
200
|
+
|
201
|
+
##
|
202
|
+
# The backup has been successfully created and is ready to serve requests.
|
203
|
+
#
|
204
|
+
# @return [Boolean]
|
205
|
+
#
|
206
|
+
def ready?
|
207
|
+
state == :READY
|
208
|
+
end
|
209
|
+
|
210
|
+
##
|
211
|
+
# Gets the [Cloud IAM](https://cloud.google.com/iam/) access control
|
212
|
+
# policy for the backup.
|
213
|
+
#
|
214
|
+
# @see https://cloud.google.com/bigtable/docs/access-control
|
215
|
+
#
|
216
|
+
# @yield [policy] A block for updating the policy. The latest policy
|
217
|
+
# will be read from the Bigtable service and passed to the block. After
|
218
|
+
# the block completes, the modified policy will be written to the
|
219
|
+
# service.
|
220
|
+
# @yieldparam [Policy] policy the current Cloud IAM Policy for this
|
221
|
+
# backup.
|
222
|
+
#
|
223
|
+
# @return [Policy] The current Cloud IAM Policy for the backup.
|
224
|
+
#
|
225
|
+
# @example
|
226
|
+
# require "google/cloud/bigtable"
|
227
|
+
#
|
228
|
+
# bigtable = Google::Cloud::Bigtable.new
|
229
|
+
# instance = bigtable.instance("my-instance")
|
230
|
+
# cluster = instance.cluster("my-cluster")
|
231
|
+
#
|
232
|
+
# backup = cluster.backup("my-backup")
|
233
|
+
#
|
234
|
+
# policy = backup.policy
|
235
|
+
#
|
236
|
+
# @example Update the policy by passing a block.
|
237
|
+
# require "google/cloud/bigtable"
|
238
|
+
#
|
239
|
+
# bigtable = Google::Cloud::Bigtable.new
|
240
|
+
# instance = bigtable.instance("my-instance")
|
241
|
+
# cluster = instance.cluster("my-cluster")
|
242
|
+
#
|
243
|
+
# backup = cluster.backup("my-backup")
|
244
|
+
#
|
245
|
+
# backup.policy do |p|
|
246
|
+
# p.add("roles/owner", "user:owner@example.com")
|
247
|
+
# end # 2 API calls
|
248
|
+
#
|
249
|
+
def policy
|
250
|
+
ensure_service!
|
251
|
+
grpc = service.get_backup_policy instance_id, cluster_id, backup_id
|
252
|
+
policy = Policy.from_grpc grpc
|
253
|
+
return policy unless block_given?
|
254
|
+
yield policy
|
255
|
+
update_policy policy
|
256
|
+
end
|
257
|
+
|
258
|
+
##
|
259
|
+
# Updates the [Cloud IAM](https://cloud.google.com/iam/) access control
|
260
|
+
# policy for the backup. The policy should be read from {#policy}.
|
261
|
+
# See {Google::Cloud::Bigtable::Policy} for an explanation of the policy
|
262
|
+
# `etag` property and how to modify policies.
|
263
|
+
#
|
264
|
+
# You can also update the policy by passing a block to {#policy}, which
|
265
|
+
# will call this method internally after the block completes.
|
266
|
+
#
|
267
|
+
# @param new_policy [Policy] a new or modified Cloud IAM Policy for this
|
268
|
+
# backup
|
269
|
+
#
|
270
|
+
# @return [Policy] The policy returned by the API update operation.
|
271
|
+
#
|
272
|
+
# @example
|
273
|
+
# require "google/cloud/bigtable"
|
274
|
+
#
|
275
|
+
# bigtable = Google::Cloud::Bigtable.new
|
276
|
+
# instance = bigtable.instance("my-instance")
|
277
|
+
# cluster = instance.cluster("my-cluster")
|
278
|
+
#
|
279
|
+
# backup = cluster.backup("my-backup")
|
280
|
+
#
|
281
|
+
# policy = backup.policy
|
282
|
+
# policy.add("roles/owner", "user:owner@example.com")
|
283
|
+
# updated_policy = backup.update_policy(policy)
|
284
|
+
#
|
285
|
+
# puts updated_policy.roles
|
286
|
+
#
|
287
|
+
def update_policy new_policy
|
288
|
+
ensure_service!
|
289
|
+
grpc = service.set_backup_policy instance_id, cluster_id, backup_id, new_policy.to_grpc
|
290
|
+
Policy.from_grpc grpc
|
291
|
+
end
|
292
|
+
alias policy= update_policy
|
293
|
+
|
294
|
+
##
|
295
|
+
# Tests the specified permissions against the [Cloud
|
296
|
+
# IAM](https://cloud.google.com/iam/) access control policy.
|
297
|
+
#
|
298
|
+
# @see https://cloud.google.com/iam/docs/managing-policies Managing Policies
|
299
|
+
# @see https://cloud.google.com/bigtable/docs/access-control Access Control
|
300
|
+
#
|
301
|
+
# @param permissions [String, Array<String>] permissions The set of permissions to
|
302
|
+
# check access for. Permissions with wildcards (such as `*` or `bigtable.*`) are
|
303
|
+
# not allowed.
|
304
|
+
# See [Access Control](https://cloud.google.com/bigtable/docs/access-control).
|
305
|
+
#
|
306
|
+
# @return [Array<String>] The permissions that are configured for the policy.
|
307
|
+
#
|
308
|
+
# @example
|
309
|
+
# require "google/cloud/bigtable"
|
310
|
+
#
|
311
|
+
# bigtable = Google::Cloud::Bigtable.new
|
312
|
+
# instance = bigtable.instance("my-instance")
|
313
|
+
# cluster = instance.cluster("my-cluster")
|
314
|
+
#
|
315
|
+
# backup = cluster.backup("my-backup")
|
316
|
+
#
|
317
|
+
# permissions = backup.test_iam_permissions(
|
318
|
+
# "bigtable.backups.delete",
|
319
|
+
# "bigtable.backups.get"
|
320
|
+
# )
|
321
|
+
# permissions.include? "bigtable.backups.delete" #=> false
|
322
|
+
# permissions.include? "bigtable.backups.get" #=> true
|
323
|
+
#
|
324
|
+
def test_iam_permissions *permissions
|
325
|
+
ensure_service!
|
326
|
+
grpc = service.test_backup_permissions instance_id, cluster_id, backup_id, permissions.flatten
|
327
|
+
grpc.permissions.to_a
|
328
|
+
end
|
329
|
+
|
330
|
+
##
|
331
|
+
# Creates a new table by restoring from a completed backup.
|
332
|
+
#
|
333
|
+
# @param table_id [String] The table ID for the new table. This table must not yet exist. Required.
|
334
|
+
#
|
335
|
+
# @return [Google::Cloud::Bigtable::Table::RestoreJob] The job representing the long-running, asynchronous
|
336
|
+
# processing of a backup restore table operation.
|
337
|
+
#
|
338
|
+
# @example
|
339
|
+
# require "google/cloud/bigtable"
|
340
|
+
#
|
341
|
+
# bigtable = Google::Cloud::Bigtable.new
|
342
|
+
# instance = bigtable.instance("my-instance")
|
343
|
+
# cluster = instance.cluster("my-cluster")
|
344
|
+
#
|
345
|
+
# backup = cluster.backup("my-backup")
|
346
|
+
#
|
347
|
+
# job = backup.restore("my-new-table")
|
348
|
+
#
|
349
|
+
# job.wait_until_done!
|
350
|
+
# job.done? #=> true
|
351
|
+
#
|
352
|
+
# if job.error?
|
353
|
+
# status = job.error
|
354
|
+
# else
|
355
|
+
# table = job.table
|
356
|
+
# optimized = job.optimize_table_operation_name
|
357
|
+
# end
|
358
|
+
#
|
359
|
+
def restore table_id
|
360
|
+
grpc = service.restore_table table_id, instance_id, cluster_id, backup_id
|
361
|
+
Table::RestoreJob.from_grpc grpc, service
|
362
|
+
end
|
363
|
+
|
364
|
+
##
|
365
|
+
# Updates the backup.
|
366
|
+
#
|
367
|
+
# `expire_time` is the only updatable field.
|
368
|
+
#
|
369
|
+
# @return [Boolean] Returns `true` if the update succeeded.
|
370
|
+
#
|
371
|
+
# @example
|
372
|
+
# require "google/cloud/bigtable"
|
373
|
+
#
|
374
|
+
# bigtable = Google::Cloud::Bigtable.new
|
375
|
+
# instance = bigtable.instance("my-instance")
|
376
|
+
# cluster = instance.cluster("my-cluster")
|
377
|
+
#
|
378
|
+
# backup = cluster.backup("my-backup")
|
379
|
+
#
|
380
|
+
# # Update
|
381
|
+
# backup.expire_time = Time.now + 60 * 60 * 7
|
382
|
+
# backup.save
|
383
|
+
#
|
384
|
+
def save
|
385
|
+
ensure_service!
|
386
|
+
@grpc = service.update_backup @grpc, [:expire_time]
|
387
|
+
true
|
388
|
+
end
|
389
|
+
alias update save
|
390
|
+
|
391
|
+
##
|
392
|
+
# Reloads backup data.
|
393
|
+
#
|
394
|
+
# @return [Google::Cloud::Bigtable::Backup]
|
395
|
+
#
|
396
|
+
def reload!
|
397
|
+
@grpc = service.get_backup instance_id, cluster_id, backup_id
|
398
|
+
self
|
399
|
+
end
|
400
|
+
|
401
|
+
##
|
402
|
+
# Permanently deletes the backup.
|
403
|
+
#
|
404
|
+
# @return [Boolean] Returns `true` if the backup was deleted.
|
405
|
+
#
|
406
|
+
# @example
|
407
|
+
# require "google/cloud/bigtable"
|
408
|
+
#
|
409
|
+
# bigtable = Google::Cloud::Bigtable.new
|
410
|
+
# instance = bigtable.instance("my-instance")
|
411
|
+
# cluster = instance.cluster("my-cluster")
|
412
|
+
#
|
413
|
+
# backup = cluster.backup("my-backup")
|
414
|
+
#
|
415
|
+
# backup.delete
|
416
|
+
#
|
417
|
+
def delete
|
418
|
+
ensure_service!
|
419
|
+
service.delete_backup instance_id, cluster_id, backup_id
|
420
|
+
true
|
421
|
+
end
|
422
|
+
|
423
|
+
# @private
|
424
|
+
#
|
425
|
+
# Creates a new Backup instance from a Google::Cloud::Bigtable::Admin::V2::Backup.
|
426
|
+
#
|
427
|
+
# @param grpc [Google::Cloud::Bigtable::Admin::V2::Backup]
|
428
|
+
# @param service [Google::Cloud::Bigtable::Service]
|
429
|
+
# @return [Google::Cloud::Bigtable::Backup]
|
430
|
+
def self.from_grpc grpc, service
|
431
|
+
new grpc, service
|
432
|
+
end
|
433
|
+
|
434
|
+
protected
|
435
|
+
|
436
|
+
# @private
|
437
|
+
#
|
438
|
+
# Raise an error unless an active connection to the service is available.
|
439
|
+
def ensure_service!
|
440
|
+
raise "Must have active connection to service" unless service
|
441
|
+
end
|
442
|
+
end
|
443
|
+
end
|
444
|
+
end
|
445
|
+
end
|