google-cloud-bigtable 0.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 +7 -0
- data/.yardopts +10 -0
- data/LICENSE +201 -0
- data/README.md +65 -0
- data/lib/google/bigtable/admin/v2/bigtable_instance_admin_pb.rb +139 -0
- data/lib/google/bigtable/admin/v2/bigtable_instance_admin_services_pb.rb +85 -0
- data/lib/google/bigtable/admin/v2/bigtable_table_admin_pb.rb +137 -0
- data/lib/google/bigtable/admin/v2/bigtable_table_admin_services_pb.rb +117 -0
- data/lib/google/bigtable/admin/v2/common_pb.rb +24 -0
- data/lib/google/bigtable/admin/v2/instance_pb.rb +72 -0
- data/lib/google/bigtable/admin/v2/table_pb.rb +88 -0
- data/lib/google/bigtable/v2/bigtable_pb.rb +109 -0
- data/lib/google/bigtable/v2/bigtable_services_pb.rb +67 -0
- data/lib/google/bigtable/v2/data_pb.rb +155 -0
- data/lib/google/cloud/bigtable/admin/credentials.rb +26 -0
- data/lib/google/cloud/bigtable/admin/v2/bigtable_instance_admin_client.rb +1417 -0
- data/lib/google/cloud/bigtable/admin/v2/bigtable_instance_admin_client_config.json +123 -0
- data/lib/google/cloud/bigtable/admin/v2/bigtable_table_admin_client.rb +1079 -0
- data/lib/google/cloud/bigtable/admin/v2/bigtable_table_admin_client_config.json +109 -0
- data/lib/google/cloud/bigtable/admin/v2/credentials.rb +50 -0
- data/lib/google/cloud/bigtable/admin/v2/doc/google/bigtable/admin/v2/bigtable_instance_admin.rb +279 -0
- data/lib/google/cloud/bigtable/admin/v2/doc/google/bigtable/admin/v2/bigtable_table_admin.rb +353 -0
- data/lib/google/cloud/bigtable/admin/v2/doc/google/bigtable/admin/v2/instance.rb +194 -0
- data/lib/google/cloud/bigtable/admin/v2/doc/google/bigtable/admin/v2/table.rb +209 -0
- data/lib/google/cloud/bigtable/admin/v2/doc/google/iam/v1/iam_policy.rb +62 -0
- data/lib/google/cloud/bigtable/admin/v2/doc/google/iam/v1/policy.rb +127 -0
- data/lib/google/cloud/bigtable/admin/v2/doc/google/longrunning/operations.rb +92 -0
- data/lib/google/cloud/bigtable/admin/v2/doc/google/protobuf/any.rb +124 -0
- data/lib/google/cloud/bigtable/admin/v2/doc/google/protobuf/duration.rb +90 -0
- data/lib/google/cloud/bigtable/admin/v2/doc/google/protobuf/empty.rb +28 -0
- data/lib/google/cloud/bigtable/admin/v2/doc/google/protobuf/field_mask.rb +223 -0
- data/lib/google/cloud/bigtable/admin/v2/doc/google/protobuf/timestamp.rb +106 -0
- data/lib/google/cloud/bigtable/admin/v2/doc/google/rpc/status.rb +83 -0
- data/lib/google/cloud/bigtable/admin/v2.rb +200 -0
- data/lib/google/cloud/bigtable/admin.rb +196 -0
- data/lib/google/cloud/bigtable/app_profile/job.rb +102 -0
- data/lib/google/cloud/bigtable/app_profile/list.rb +159 -0
- data/lib/google/cloud/bigtable/app_profile.rb +373 -0
- data/lib/google/cloud/bigtable/chunk_processor.rb +253 -0
- data/lib/google/cloud/bigtable/cluster/job.rb +92 -0
- data/lib/google/cloud/bigtable/cluster/list.rb +169 -0
- data/lib/google/cloud/bigtable/cluster.rb +264 -0
- data/lib/google/cloud/bigtable/column_family.rb +280 -0
- data/lib/google/cloud/bigtable/column_range.rb +186 -0
- data/lib/google/cloud/bigtable/convert.rb +75 -0
- data/lib/google/cloud/bigtable/credentials.rb +24 -0
- data/lib/google/cloud/bigtable/errors.rb +35 -0
- data/lib/google/cloud/bigtable/gc_rule.rb +215 -0
- data/lib/google/cloud/bigtable/instance/cluster_map.rb +70 -0
- data/lib/google/cloud/bigtable/instance/job.rb +97 -0
- data/lib/google/cloud/bigtable/instance/list.rb +159 -0
- data/lib/google/cloud/bigtable/instance.rb +921 -0
- data/lib/google/cloud/bigtable/longrunning_job.rb +105 -0
- data/lib/google/cloud/bigtable/mutation_entry.rb +244 -0
- data/lib/google/cloud/bigtable/mutation_operations.rb +338 -0
- data/lib/google/cloud/bigtable/policy.rb +163 -0
- data/lib/google/cloud/bigtable/project.rb +580 -0
- data/lib/google/cloud/bigtable/read_modify_write_rule.rb +129 -0
- data/lib/google/cloud/bigtable/read_operations.rb +345 -0
- data/lib/google/cloud/bigtable/row.rb +125 -0
- data/lib/google/cloud/bigtable/row_filter/chain_filter.rb +539 -0
- data/lib/google/cloud/bigtable/row_filter/condition_filter.rb +108 -0
- data/lib/google/cloud/bigtable/row_filter/interleave_filter.rb +570 -0
- data/lib/google/cloud/bigtable/row_filter/simple_filter.rb +273 -0
- data/lib/google/cloud/bigtable/row_filter.rb +593 -0
- data/lib/google/cloud/bigtable/row_range.rb +174 -0
- data/lib/google/cloud/bigtable/rows_mutator.rb +120 -0
- data/lib/google/cloud/bigtable/rows_reader.rb +196 -0
- data/lib/google/cloud/bigtable/sample_row_key.rb +82 -0
- data/lib/google/cloud/bigtable/service.rb +817 -0
- data/lib/google/cloud/bigtable/table/cluster_state.rb +93 -0
- data/lib/google/cloud/bigtable/table/column_family_map.rb +68 -0
- data/lib/google/cloud/bigtable/table/list.rb +147 -0
- data/lib/google/cloud/bigtable/table.rb +676 -0
- data/lib/google/cloud/bigtable/v2/bigtable_client.rb +579 -0
- data/lib/google/cloud/bigtable/v2/bigtable_client_config.json +65 -0
- data/lib/google/cloud/bigtable/v2/credentials.rb +45 -0
- data/lib/google/cloud/bigtable/v2/doc/google/bigtable/v2/bigtable.rb +286 -0
- data/lib/google/cloud/bigtable/v2/doc/google/bigtable/v2/data.rb +492 -0
- data/lib/google/cloud/bigtable/v2/doc/google/protobuf/any.rb +124 -0
- data/lib/google/cloud/bigtable/v2/doc/google/protobuf/wrappers.rb +89 -0
- data/lib/google/cloud/bigtable/v2/doc/google/rpc/status.rb +83 -0
- data/lib/google/cloud/bigtable/v2.rb +132 -0
- data/lib/google/cloud/bigtable/value_range.rb +175 -0
- data/lib/google/cloud/bigtable/version.rb +22 -0
- data/lib/google/cloud/bigtable.rb +223 -0
- data/lib/google-cloud-bigtable.rb +167 -0
- metadata +283 -0
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
# Copyright 2018 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
|
+
require "google/gax"
|
|
16
|
+
require "pathname"
|
|
17
|
+
|
|
18
|
+
module Google
|
|
19
|
+
module Cloud
|
|
20
|
+
module Bigtable
|
|
21
|
+
# rubocop:disable LineLength
|
|
22
|
+
|
|
23
|
+
##
|
|
24
|
+
# # Ruby Client for Cloud Bigtable Admin API ([Alpha](https://github.com/GoogleCloudPlatform/google-cloud-ruby#versioning))
|
|
25
|
+
#
|
|
26
|
+
# [Cloud Bigtable Admin API][Product Documentation]:
|
|
27
|
+
#
|
|
28
|
+
# - [Product Documentation][]
|
|
29
|
+
#
|
|
30
|
+
# ## Quick Start
|
|
31
|
+
# In order to use this library, you first need to go through the following
|
|
32
|
+
# steps:
|
|
33
|
+
#
|
|
34
|
+
# 1. [Select or create a Cloud Platform project.](https://console.cloud.google.com/project)
|
|
35
|
+
# 2. [Enable billing for your project.](https://cloud.google.com/billing/docs/how-to/modify-project#enable_billing_for_a_project)
|
|
36
|
+
# 3. [Enable the Cloud Bigtable Admin API.](https://console.cloud.google.com/apis/library/bigtableadmin.googleapis.com)
|
|
37
|
+
# 4. [Setup Authentication.](https://googlecloudplatform.github.io/google-cloud-ruby/#/docs/google-cloud/master/guides/authentication)
|
|
38
|
+
#
|
|
39
|
+
# ### Next Steps
|
|
40
|
+
# - Read the [Cloud Bigtable Admin API Product documentation][Product Documentation]
|
|
41
|
+
# to learn more about the product and see How-to Guides.
|
|
42
|
+
# - View this [repository's main README](https://github.com/GoogleCloudPlatform/google-cloud-ruby/blob/master/README.md)
|
|
43
|
+
# to see the full list of Cloud APIs that we cover.
|
|
44
|
+
#
|
|
45
|
+
# [Product Documentation]: https://cloud.google.com/bigtable-admin
|
|
46
|
+
#
|
|
47
|
+
# ## Enabling Logging
|
|
48
|
+
#
|
|
49
|
+
# To enable logging for this library, set the logger for the underlying [gRPC](https://github.com/grpc/grpc/tree/master/src/ruby) library.
|
|
50
|
+
# 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,
|
|
51
|
+
# or a [`Google::Cloud::Logging::Logger`](https://googlecloudplatform.github.io/google-cloud-ruby/#/docs/google-cloud-logging/latest/google/cloud/logging/logger)
|
|
52
|
+
# 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)
|
|
53
|
+
# and the gRPC [spec_helper.rb](https://github.com/grpc/grpc/blob/master/src/ruby/spec/spec_helper.rb) for additional information.
|
|
54
|
+
#
|
|
55
|
+
# Configuring a Ruby stdlib logger:
|
|
56
|
+
#
|
|
57
|
+
# ```ruby
|
|
58
|
+
# require "logger"
|
|
59
|
+
#
|
|
60
|
+
# module MyLogger
|
|
61
|
+
# LOGGER = Logger.new $stderr, level: Logger::WARN
|
|
62
|
+
# def logger
|
|
63
|
+
# LOGGER
|
|
64
|
+
# end
|
|
65
|
+
# end
|
|
66
|
+
#
|
|
67
|
+
# # Define a gRPC module-level logger method before grpc/logconfig.rb loads.
|
|
68
|
+
# module GRPC
|
|
69
|
+
# extend MyLogger
|
|
70
|
+
# end
|
|
71
|
+
# ```
|
|
72
|
+
#
|
|
73
|
+
module Admin
|
|
74
|
+
# rubocop:enable LineLength
|
|
75
|
+
|
|
76
|
+
FILE_DIR = File.realdirpath(Pathname.new(__FILE__).join("..").join("admin"))
|
|
77
|
+
|
|
78
|
+
AVAILABLE_VERSIONS = Dir["#{FILE_DIR}/*"]
|
|
79
|
+
.select { |file| File.directory?(file) }
|
|
80
|
+
.select { |dir| Google::Gax::VERSION_MATCHER.match(File.basename(dir)) }
|
|
81
|
+
.select { |dir| File.exist?(dir + ".rb") }
|
|
82
|
+
.map { |dir| File.basename(dir) }
|
|
83
|
+
|
|
84
|
+
module BigtableInstanceAdmin
|
|
85
|
+
##
|
|
86
|
+
# Service for creating, configuring, and deleting Cloud Bigtable Instances and
|
|
87
|
+
# Clusters. Provides access to the Instance and Cluster schemas only, not the
|
|
88
|
+
# tables' metadata or data stored in those tables.
|
|
89
|
+
#
|
|
90
|
+
# @param version [Symbol, String]
|
|
91
|
+
# The major version of the service to be used. By default :v2
|
|
92
|
+
# is used.
|
|
93
|
+
# @overload new(version:, credentials:, scopes:, client_config:, timeout:)
|
|
94
|
+
# @param credentials [Google::Auth::Credentials, String, Hash, GRPC::Core::Channel, GRPC::Core::ChannelCredentials, Proc]
|
|
95
|
+
# Provides the means for authenticating requests made by the client. This parameter can
|
|
96
|
+
# be many types.
|
|
97
|
+
# A `Google::Auth::Credentials` uses a the properties of its represented keyfile for
|
|
98
|
+
# authenticating requests made by this client.
|
|
99
|
+
# A `String` will be treated as the path to the keyfile to be used for the construction of
|
|
100
|
+
# credentials for this client.
|
|
101
|
+
# A `Hash` will be treated as the contents of a keyfile to be used for the construction of
|
|
102
|
+
# credentials for this client.
|
|
103
|
+
# A `GRPC::Core::Channel` will be used to make calls through.
|
|
104
|
+
# A `GRPC::Core::ChannelCredentials` for the setting up the RPC client. The channel credentials
|
|
105
|
+
# should already be composed with a `GRPC::Core::CallCredentials` object.
|
|
106
|
+
# A `Proc` will be used as an updater_proc for the Grpc channel. The proc transforms the
|
|
107
|
+
# metadata for requests, generally, to give OAuth credentials.
|
|
108
|
+
# @param scopes [Array<String>]
|
|
109
|
+
# The OAuth scopes for this service. This parameter is ignored if
|
|
110
|
+
# an updater_proc is supplied.
|
|
111
|
+
# @param client_config [Hash]
|
|
112
|
+
# A Hash for call options for each method. See
|
|
113
|
+
# Google::Gax#construct_settings for the structure of
|
|
114
|
+
# this data. Falls back to the default config if not specified
|
|
115
|
+
# or the specified config is missing data points.
|
|
116
|
+
# @param timeout [Numeric]
|
|
117
|
+
# The default timeout, in seconds, for calls made through this client.
|
|
118
|
+
# @param metadata [Hash]
|
|
119
|
+
# Default metadata to be sent with each request. This can be overridden on a per call basis.
|
|
120
|
+
# @param exception_transformer [Proc]
|
|
121
|
+
# An optional proc that intercepts any exceptions raised during an API call to inject
|
|
122
|
+
# custom error handling.
|
|
123
|
+
def self.new(*args, version: :v2, **kwargs)
|
|
124
|
+
unless AVAILABLE_VERSIONS.include?(version.to_s.downcase)
|
|
125
|
+
raise "The version: #{version} is not available. The available versions " \
|
|
126
|
+
"are: [#{AVAILABLE_VERSIONS.join(", ")}]"
|
|
127
|
+
end
|
|
128
|
+
|
|
129
|
+
require "#{FILE_DIR}/#{version.to_s.downcase}"
|
|
130
|
+
version_module = Google::Cloud::Bigtable::Admin
|
|
131
|
+
.constants
|
|
132
|
+
.select {|sym| sym.to_s.downcase == version.to_s.downcase}
|
|
133
|
+
.first
|
|
134
|
+
Google::Cloud::Bigtable::Admin.const_get(version_module)::BigtableInstanceAdmin.new(*args, **kwargs)
|
|
135
|
+
end
|
|
136
|
+
end
|
|
137
|
+
|
|
138
|
+
module BigtableTableAdmin
|
|
139
|
+
##
|
|
140
|
+
# Service for creating, configuring, and deleting Cloud Bigtable tables.
|
|
141
|
+
#
|
|
142
|
+
#
|
|
143
|
+
# Provides access to the table schemas only, not the data stored within
|
|
144
|
+
# the tables.
|
|
145
|
+
#
|
|
146
|
+
# @param version [Symbol, String]
|
|
147
|
+
# The major version of the service to be used. By default :v2
|
|
148
|
+
# is used.
|
|
149
|
+
# @overload new(version:, credentials:, scopes:, client_config:, timeout:)
|
|
150
|
+
# @param credentials [Google::Auth::Credentials, String, Hash, GRPC::Core::Channel, GRPC::Core::ChannelCredentials, Proc]
|
|
151
|
+
# Provides the means for authenticating requests made by the client. This parameter can
|
|
152
|
+
# be many types.
|
|
153
|
+
# A `Google::Auth::Credentials` uses a the properties of its represented keyfile for
|
|
154
|
+
# authenticating requests made by this client.
|
|
155
|
+
# A `String` will be treated as the path to the keyfile to be used for the construction of
|
|
156
|
+
# credentials for this client.
|
|
157
|
+
# A `Hash` will be treated as the contents of a keyfile to be used for the construction of
|
|
158
|
+
# credentials for this client.
|
|
159
|
+
# A `GRPC::Core::Channel` will be used to make calls through.
|
|
160
|
+
# A `GRPC::Core::ChannelCredentials` for the setting up the RPC client. The channel credentials
|
|
161
|
+
# should already be composed with a `GRPC::Core::CallCredentials` object.
|
|
162
|
+
# A `Proc` will be used as an updater_proc for the Grpc channel. The proc transforms the
|
|
163
|
+
# metadata for requests, generally, to give OAuth credentials.
|
|
164
|
+
# @param scopes [Array<String>]
|
|
165
|
+
# The OAuth scopes for this service. This parameter is ignored if
|
|
166
|
+
# an updater_proc is supplied.
|
|
167
|
+
# @param client_config [Hash]
|
|
168
|
+
# A Hash for call options for each method. See
|
|
169
|
+
# Google::Gax#construct_settings for the structure of
|
|
170
|
+
# this data. Falls back to the default config if not specified
|
|
171
|
+
# or the specified config is missing data points.
|
|
172
|
+
# @param timeout [Numeric]
|
|
173
|
+
# The default timeout, in seconds, for calls made through this client.
|
|
174
|
+
# @param metadata [Hash]
|
|
175
|
+
# Default metadata to be sent with each request. This can be overridden on a per call basis.
|
|
176
|
+
# @param exception_transformer [Proc]
|
|
177
|
+
# An optional proc that intercepts any exceptions raised during an API call to inject
|
|
178
|
+
# custom error handling.
|
|
179
|
+
def self.new(*args, version: :v2, **kwargs)
|
|
180
|
+
unless AVAILABLE_VERSIONS.include?(version.to_s.downcase)
|
|
181
|
+
raise "The version: #{version} is not available. The available versions " \
|
|
182
|
+
"are: [#{AVAILABLE_VERSIONS.join(", ")}]"
|
|
183
|
+
end
|
|
184
|
+
|
|
185
|
+
require "#{FILE_DIR}/#{version.to_s.downcase}"
|
|
186
|
+
version_module = Google::Cloud::Bigtable::Admin
|
|
187
|
+
.constants
|
|
188
|
+
.select {|sym| sym.to_s.downcase == version.to_s.downcase}
|
|
189
|
+
.first
|
|
190
|
+
Google::Cloud::Bigtable::Admin.const_get(version_module)::BigtableTableAdmin.new(*args, **kwargs)
|
|
191
|
+
end
|
|
192
|
+
end
|
|
193
|
+
end
|
|
194
|
+
end
|
|
195
|
+
end
|
|
196
|
+
end
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
# Copyright 2018 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 AppProfile
|
|
20
|
+
# # Job
|
|
21
|
+
#
|
|
22
|
+
# A resource representing the long-running, asynchronous processing of
|
|
23
|
+
# an app profile create or update operation. The job can be refreshed to
|
|
24
|
+
# retrieve the app profile object once the operation has been completed.
|
|
25
|
+
#
|
|
26
|
+
# See {AppProfile#save}.
|
|
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
|
+
#
|
|
36
|
+
# instance = bigtable.instance("my-instance")
|
|
37
|
+
# app_profile = bigtable.instance("my-app-profile")
|
|
38
|
+
#
|
|
39
|
+
# app_profile.description = "User data instance app profile"
|
|
40
|
+
# routing_policy = Google::Cloud::Bigtable::AppProfile.single_cluster_routing(
|
|
41
|
+
# "my-cluster",
|
|
42
|
+
# allow_transactional_writes: true
|
|
43
|
+
# )
|
|
44
|
+
# app_profile.routing_policy = routing_policy
|
|
45
|
+
#
|
|
46
|
+
# job = app_profile.save
|
|
47
|
+
#
|
|
48
|
+
# job.done? #=> false
|
|
49
|
+
# job.reload! # API call
|
|
50
|
+
# job.done? #=> true
|
|
51
|
+
#
|
|
52
|
+
# # OR
|
|
53
|
+
# job.wait_until_done!
|
|
54
|
+
#
|
|
55
|
+
# if job.error?
|
|
56
|
+
# status = job.error
|
|
57
|
+
# else
|
|
58
|
+
# app_profile = job.app_profile
|
|
59
|
+
# end
|
|
60
|
+
#
|
|
61
|
+
class Job < LongrunningJob
|
|
62
|
+
# The instance that is the object of the operation.
|
|
63
|
+
#
|
|
64
|
+
# @return [Google::Cloud::Bigtable::AppProfile, nil] The app profile instance, or
|
|
65
|
+
# `nil` if the operation is not complete.
|
|
66
|
+
#
|
|
67
|
+
# @example
|
|
68
|
+
# require "google/cloud/bigtable"
|
|
69
|
+
#
|
|
70
|
+
# bigtable = Google::Cloud::Bigtable.new
|
|
71
|
+
#
|
|
72
|
+
# instance = bigtable.instance("my-instance")
|
|
73
|
+
# app_profile = bigtable.instance("my-app-profile")
|
|
74
|
+
#
|
|
75
|
+
# app_profile.description = "User data instance app profile"
|
|
76
|
+
# routing_policy = Google::Cloud::Bigtable::AppProfile.single_cluster_routing(
|
|
77
|
+
# "my-cluster",
|
|
78
|
+
# allow_transactional_writes: true
|
|
79
|
+
# )
|
|
80
|
+
# app_profile.routing_policy = routing_policy
|
|
81
|
+
#
|
|
82
|
+
# job = app_profile.save
|
|
83
|
+
#
|
|
84
|
+
# job.done? #=> false
|
|
85
|
+
# job.reload!
|
|
86
|
+
# job.done? #=> true
|
|
87
|
+
#
|
|
88
|
+
# # OR
|
|
89
|
+
# job.wait_until_done!
|
|
90
|
+
#
|
|
91
|
+
# app_profile = job.app_profile
|
|
92
|
+
#
|
|
93
|
+
def app_profile
|
|
94
|
+
return nil unless done?
|
|
95
|
+
return nil unless @grpc.grpc_op.result == :response
|
|
96
|
+
AppProfile.from_grpc(@grpc.results, service)
|
|
97
|
+
end
|
|
98
|
+
end
|
|
99
|
+
end
|
|
100
|
+
end
|
|
101
|
+
end
|
|
102
|
+
end
|
|
@@ -0,0 +1,159 @@
|
|
|
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 AppProfile
|
|
22
|
+
# AppProfile::List is a special case Array with additional
|
|
23
|
+
# values.
|
|
24
|
+
class List < DelegateClass(::Array)
|
|
25
|
+
# @private
|
|
26
|
+
# The gRPC Service object.
|
|
27
|
+
attr_accessor :service
|
|
28
|
+
|
|
29
|
+
# @private
|
|
30
|
+
# The gRPC page enumbrable object.
|
|
31
|
+
attr_accessor :grpc
|
|
32
|
+
|
|
33
|
+
# @private
|
|
34
|
+
# Create a new AppProfile::List with an array of Snapshot instances.
|
|
35
|
+
def initialize arr = []
|
|
36
|
+
super(arr)
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
# Whether there is a next page of instances.
|
|
40
|
+
#
|
|
41
|
+
# @return [Boolean]
|
|
42
|
+
#
|
|
43
|
+
# @example
|
|
44
|
+
# require "google/cloud/bigtable"
|
|
45
|
+
#
|
|
46
|
+
# bigtable = Google::Cloud::Bigtable.new
|
|
47
|
+
#
|
|
48
|
+
# instance = bigtable.instance("my-instance")
|
|
49
|
+
# app_profiles = instance.app_profiles
|
|
50
|
+
#
|
|
51
|
+
# if app_profiles.next?
|
|
52
|
+
# next_app_profiles = app_profiles.next
|
|
53
|
+
# end
|
|
54
|
+
def next?
|
|
55
|
+
grpc.next_page?
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
# Retrieve the next page of app_profiles.
|
|
59
|
+
#
|
|
60
|
+
# @return [AppProfile::List] The list of instances.
|
|
61
|
+
#
|
|
62
|
+
# @example
|
|
63
|
+
# require "google/cloud/bigtable"
|
|
64
|
+
#
|
|
65
|
+
# bigtable = Google::Cloud::Bigtable.new
|
|
66
|
+
#
|
|
67
|
+
# instance = bigtable.instance("my-instance")
|
|
68
|
+
# app_profiles = instance.app_profiles
|
|
69
|
+
#
|
|
70
|
+
# if app_profiles.next?
|
|
71
|
+
# next_app_profiles = app_profiles.next
|
|
72
|
+
# end
|
|
73
|
+
def next
|
|
74
|
+
ensure_grpc!
|
|
75
|
+
|
|
76
|
+
return nil unless next?
|
|
77
|
+
grpc.next_page
|
|
78
|
+
self.class.from_grpc(grpc, service)
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
# Retrieves remaining results by repeatedly invoking {#next} until
|
|
82
|
+
# {#next?} returns `false`. Calls the given block once for each
|
|
83
|
+
# result, which is passed as the argument to the block.
|
|
84
|
+
#
|
|
85
|
+
# An Enumerator is returned if no block is given.
|
|
86
|
+
#
|
|
87
|
+
# This method will make repeated API calls until all remaining results
|
|
88
|
+
# are retrieved. (Unlike `#each`, for example, which merely iterates
|
|
89
|
+
# over the results returned by a single API call.) Use with caution.
|
|
90
|
+
#
|
|
91
|
+
# @yield [app_profile] The block for accessing each instance.
|
|
92
|
+
# @yieldparam [AppProfile] instance The instance object.
|
|
93
|
+
#
|
|
94
|
+
# @return [Enumerator]
|
|
95
|
+
#
|
|
96
|
+
# @example Iterating each instance by passing a block:
|
|
97
|
+
# require "google/cloud/bigtable"
|
|
98
|
+
#
|
|
99
|
+
# bigtable = Google::Cloud::Bigtable.new
|
|
100
|
+
#
|
|
101
|
+
# instance = bigtable.instance("my-instance")
|
|
102
|
+
# app_profiles = instance.app_profiles
|
|
103
|
+
#
|
|
104
|
+
# instance.app_profiles.all do |app_profile|
|
|
105
|
+
# puts app_profile.name
|
|
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
|
+
# instance = bigtable.instance("my-instance")
|
|
114
|
+
#
|
|
115
|
+
# all_snapshot_ids = instance.app_profiles.all.map do |app_profile|
|
|
116
|
+
# app_profile.name
|
|
117
|
+
# end
|
|
118
|
+
#
|
|
119
|
+
def all
|
|
120
|
+
return enum_for(:all) unless block_given?
|
|
121
|
+
|
|
122
|
+
results = self
|
|
123
|
+
loop do
|
|
124
|
+
results.each { |r| yield r }
|
|
125
|
+
break unless next?
|
|
126
|
+
grpc.next_page
|
|
127
|
+
results = self.class.from_grpc(grpc, service)
|
|
128
|
+
end
|
|
129
|
+
end
|
|
130
|
+
|
|
131
|
+
# @private
|
|
132
|
+
# New Snapshot::List from a Google::Gax::PagedEnumerable<Google::Bigtable::Admin::V2::AppProfile> object.
|
|
133
|
+
# @param grpc [Google::Gax::PagedEnumerable<Google::Bigtable::Admin::V2::AppProfile> ]
|
|
134
|
+
# @param service [Google::Cloud::Bigtable::Service]
|
|
135
|
+
# @return [Array<Google::Cloud::Bigtable::AppProfile>]
|
|
136
|
+
def self.from_grpc grpc, service
|
|
137
|
+
app_profiles = List.new(
|
|
138
|
+
Array(grpc.response.app_profiles).map do |app_profile|
|
|
139
|
+
AppProfile.from_grpc(app_profile, service)
|
|
140
|
+
end
|
|
141
|
+
)
|
|
142
|
+
app_profiles.grpc = grpc
|
|
143
|
+
app_profiles.service = service
|
|
144
|
+
app_profiles
|
|
145
|
+
end
|
|
146
|
+
|
|
147
|
+
protected
|
|
148
|
+
|
|
149
|
+
# @private
|
|
150
|
+
#
|
|
151
|
+
# Raise an error if active grpc call is not available.
|
|
152
|
+
def ensure_grpc!
|
|
153
|
+
raise "Must have active grpc call" unless grpc
|
|
154
|
+
end
|
|
155
|
+
end
|
|
156
|
+
end
|
|
157
|
+
end
|
|
158
|
+
end
|
|
159
|
+
end
|