google-cloud-bigtable 0.6.2 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (49) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +36 -0
  3. data/CONTRIBUTING.md +1 -1
  4. data/lib/google-cloud-bigtable.rb +19 -21
  5. data/lib/google/cloud/bigtable.rb +11 -17
  6. data/lib/google/cloud/bigtable/app_profile.rb +148 -82
  7. data/lib/google/cloud/bigtable/app_profile/job.rb +5 -8
  8. data/lib/google/cloud/bigtable/app_profile/list.rb +11 -5
  9. data/lib/google/cloud/bigtable/chunk_processor.rb +23 -35
  10. data/lib/google/cloud/bigtable/cluster.rb +38 -11
  11. data/lib/google/cloud/bigtable/cluster/job.rb +3 -7
  12. data/lib/google/cloud/bigtable/cluster/list.rb +20 -18
  13. data/lib/google/cloud/bigtable/column_family.rb +22 -229
  14. data/lib/google/cloud/bigtable/column_family_map.rb +426 -0
  15. data/lib/google/cloud/bigtable/column_range.rb +9 -1
  16. data/lib/google/cloud/bigtable/convert.rb +12 -4
  17. data/lib/google/cloud/bigtable/errors.rb +4 -1
  18. data/lib/google/cloud/bigtable/gc_rule.rb +184 -65
  19. data/lib/google/cloud/bigtable/instance.rb +136 -126
  20. data/lib/google/cloud/bigtable/instance/cluster_map.rb +9 -7
  21. data/lib/google/cloud/bigtable/instance/job.rb +4 -3
  22. data/lib/google/cloud/bigtable/instance/list.rb +14 -9
  23. data/lib/google/cloud/bigtable/longrunning_job.rb +6 -0
  24. data/lib/google/cloud/bigtable/mutation_entry.rb +19 -23
  25. data/lib/google/cloud/bigtable/mutation_operations.rb +82 -29
  26. data/lib/google/cloud/bigtable/policy.rb +9 -5
  27. data/lib/google/cloud/bigtable/project.rb +62 -140
  28. data/lib/google/cloud/bigtable/read_modify_write_rule.rb +9 -4
  29. data/lib/google/cloud/bigtable/read_operations.rb +28 -41
  30. data/lib/google/cloud/bigtable/routing_policy.rb +171 -0
  31. data/lib/google/cloud/bigtable/row.rb +18 -7
  32. data/lib/google/cloud/bigtable/row_filter.rb +49 -20
  33. data/lib/google/cloud/bigtable/row_filter/chain_filter.rb +71 -43
  34. data/lib/google/cloud/bigtable/row_filter/condition_filter.rb +4 -1
  35. data/lib/google/cloud/bigtable/row_filter/interleave_filter.rb +74 -43
  36. data/lib/google/cloud/bigtable/row_filter/simple_filter.rb +22 -7
  37. data/lib/google/cloud/bigtable/row_range.rb +5 -0
  38. data/lib/google/cloud/bigtable/rows_mutator.rb +14 -17
  39. data/lib/google/cloud/bigtable/rows_reader.rb +18 -14
  40. data/lib/google/cloud/bigtable/sample_row_key.rb +5 -2
  41. data/lib/google/cloud/bigtable/service.rb +161 -242
  42. data/lib/google/cloud/bigtable/status.rb +76 -0
  43. data/lib/google/cloud/bigtable/table.rb +141 -236
  44. data/lib/google/cloud/bigtable/table/cluster_state.rb +7 -1
  45. data/lib/google/cloud/bigtable/table/list.rb +14 -7
  46. data/lib/google/cloud/bigtable/value_range.rb +5 -0
  47. data/lib/google/cloud/bigtable/version.rb +1 -1
  48. metadata +27 -25
  49. data/lib/google/cloud/bigtable/table/column_family_map.rb +0 -70
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 204a51cfb08c7ea7a45b1700011de87612270cc16024521f93abde0de4d3315d
4
- data.tar.gz: ee65018c352bd6aeab7958e2a7c35833ed4285c839106c8d638e6066db71b00c
3
+ metadata.gz: 833d4009bf7801aeea418cc20c01957beb3aa7717eae7660aef91c4afc1b09c5
4
+ data.tar.gz: 95a806973acd438380803a215e1fdfb3d06846b66363ee541419ebe7f54cb507
5
5
  SHA512:
6
- metadata.gz: da6d13d7f2bbcd4952f4e98859c765da3ee47ab236ba4656148dc928e55de2ccb2f7d8231d15f23dbe84e9118e2712d48ce95c6e07a6b75f3344dcb9177d560f
7
- data.tar.gz: af744f8795db5b57843bd101bbaa9d541c71d272339b97d56600606d4810bc0aaef04e28530a26ee2f5a933cc9d7e5dfa3fb0b214d71d1453f466a9d64572564
6
+ metadata.gz: 7f8ba6fe01b55f0eae24961447f829ca02bb8f709ee11b75d8ec985314f673d714ebc4f71528a74da3c34911777da9cd95895c667cc74334b55fb8b786689db6
7
+ data.tar.gz: 131d9b4c4f58215ce1808eb721b4f8a01086df6a6b207503629d86a2200ceb8b871894b5d93d0246a69e72b87d9c2a665baf4ee02e5d278f263daef72a473c4d
@@ -1,5 +1,41 @@
1
1
  # Release History
2
2
 
3
+ ### 0.7.0 / 2019-10-22
4
+
5
+ #### Features
6
+
7
+ * Update Table#column_families to yield ColumnFamilyMap for updates.
8
+ * ColumnFamilyMap now manages ColumnFamily lifecycle.
9
+ * Add MutationOperations::Response.
10
+ * Add Bigtable::Status.
11
+ * Add Bigtable::RoutingPolicy.
12
+ * Update Ruby dependency to minimum of 2.4.
13
+
14
+ #### BREAKING CHANGES
15
+
16
+ * Remove ColumnFamily lifecycle methods (create, save, delete, and related class methods).
17
+ * Replaced by Table#column_families yield block.
18
+ * Move Google::Cloud::Bigtable::Table::ColumnFamilyMap to Google::Cloud::Bigtable::ColumnFamilyMap.
19
+ * This should only affect introspection, since the constructor was previously undocumented.
20
+ * Remove Project#modify_column_families.
21
+ * Replaced by Table#column_families yield block.
22
+ * Remove Table#column_family.
23
+ * Replaced by ColumnFamilyMap lifecycle methods.
24
+ * Remove Table#modify_column_families.
25
+ * Replaced by Table#column_families yield block.
26
+ * Update GcRule#union and #intersection to not return lower-level API types.
27
+ * Update all return types and parameters associated with AppProfile routing policy to not use lower-level API types.
28
+ * The new types have exactly the same API as the old types, so this change should only affect type introspection.
29
+ * Update return types of Chain and Interleave row filters to not use lower-level API types.
30
+ * Change return type of MutationOperations#mutate_rows from lower-level API types to wrapper types.
31
+ * Remove private MutationEntry#mutations from documentation.
32
+ * Update GcRule#max_age to microsecond precision.
33
+
34
+ #### Documentation
35
+
36
+ * Update sample code.
37
+ * Update documentation.
38
+
3
39
  ### 0.6.2 / 2019-10-01
4
40
 
5
41
  #### Documentation
@@ -24,7 +24,7 @@ be able to accept your pull requests.
24
24
  In order to use the google-cloud-bigtable console and run the project's tests,
25
25
  there is a small amount of setup:
26
26
 
27
- 1. Install Ruby. google-cloud-bigtable requires Ruby 2.3+. You may choose to
27
+ 1. Install Ruby. google-cloud-bigtable requires Ruby 2.4+. You may choose to
28
28
  manage your Ruby and gem installations with [RVM](https://rvm.io/),
29
29
  [rbenv](https://github.com/rbenv/rbenv), or
30
30
  [chruby](https://github.com/postmodern/chruby).
@@ -26,6 +26,7 @@ require "google/cloud/config"
26
26
 
27
27
  module Google
28
28
  module Cloud
29
+ ##
29
30
  # Creates a new object for connecting to the Cloud Bigtable service.
30
31
  #
31
32
  # For more information on connecting to Google Cloud Platform, see the
@@ -39,7 +40,8 @@ module Google
39
40
  # updater_proc is supplied.
40
41
  # @param timeout [Integer]
41
42
  # The default timeout, in seconds, for calls made through this client.
42
- # @param credentials [Google::Auth::Credentials, String, Hash, GRPC::Core::Channel, GRPC::Core::ChannelCredentials, Proc]
43
+ # @param credentials [Google::Auth::Credentials, String, Hash, GRPC::Core::Channel,
44
+ # GRPC::Core::ChannelCredentials, Proc]
43
45
  # Provides the means for authenticating requests made by the client. This parameter can
44
46
  # be one of the following types.
45
47
  # `Google::Auth::Credentials` uses the properties of its represented keyfile for
@@ -61,23 +63,23 @@ module Google
61
63
  # @return [Google::Cloud::Bigtable::Project]
62
64
  #
63
65
  # @example
64
- # require "google/cloud"
66
+ # require "google/cloud/bigtable"
65
67
  #
66
68
  # gcloud = Google::Cloud.new
67
69
  #
68
70
  # bigtable = gcloud.bigtable
69
71
  #
70
-
71
72
  def bigtable scope: nil, timeout: nil, credentials: nil, client_config: nil
72
73
  Google::Cloud.bigtable(
73
- project_id: @project,
74
- credentials: (credentials || @keyfile),
75
- scope: scope,
76
- timeout: (timeout || @timeout),
74
+ project_id: @project,
75
+ credentials: (credentials || @keyfile),
76
+ scope: scope,
77
+ timeout: (timeout || @timeout),
77
78
  client_config: client_config
78
79
  )
79
80
  end
80
81
 
82
+ ##
81
83
  # Creates a Cloud Bigtable client instance for data, table admin and instance admin
82
84
  # operations.
83
85
  #
@@ -85,7 +87,8 @@ module Google
85
87
  # Project identifier for the Bigtable service you
86
88
  # are connecting to. If not present, the default project for the
87
89
  # credentials is used.
88
- # @param credentials [Google::Auth::Credentials, String, Hash, GRPC::Core::Channel, GRPC::Core::ChannelCredentials, Proc]
90
+ # @param credentials [Google::Auth::Credentials, String, Hash, GRPC::Core::Channel,
91
+ # GRPC::Core::ChannelCredentials, Proc]
89
92
  # The means for authenticating requests made by the client. This parameter can
90
93
  # be one of the following types.
91
94
  # `Google::Auth::Credentials` uses the properties of its represented keyfile for
@@ -116,22 +119,17 @@ module Google
116
119
  # @return [Google::Cloud::Bigtable::Project]
117
120
  #
118
121
  # @example
119
- # require "google/cloud"
122
+ # require "google/cloud/bigtable"
120
123
  #
121
124
  # bigtable = Google::Cloud.bigtable
122
-
123
- def self.bigtable \
124
- project_id: nil,
125
- credentials: nil,
126
- scope: nil,
127
- timeout: nil,
128
- client_config: nil
125
+ #
126
+ def self.bigtable project_id: nil, credentials: nil, scope: nil, timeout: nil, client_config: nil
129
127
  require "google/cloud/bigtable"
130
128
  Google::Cloud::Bigtable.new(
131
- project_id: project_id,
132
- credentials: credentials,
133
- scope: scope,
134
- timeout: timeout,
129
+ project_id: project_id,
130
+ credentials: credentials,
131
+ scope: scope,
132
+ timeout: timeout,
135
133
  client_config: client_config
136
134
  )
137
135
  end
@@ -156,7 +154,7 @@ Google::Cloud.configure.add_config! :bigtable do |config|
156
154
  config.add_field! :project_id, default_project, match: String, allow_nil: true
157
155
  config.add_alias! :project, :project_id
158
156
  config.add_field! :credentials, default_creds,
159
- match: [
157
+ match: [
160
158
  String,
161
159
  Hash,
162
160
  Google::Auth::Credentials,
@@ -21,18 +21,21 @@ require "google/cloud/bigtable/project"
21
21
 
22
22
  module Google
23
23
  module Cloud
24
+ ##
24
25
  # Cloud Bigtable
25
26
  #
26
27
  # See {file:OVERVIEW.md Bigtable Overview}.
27
28
  #
28
29
  module Bigtable
30
+ ##
29
31
  # Service for managing Cloud Bigtable instances and tables and for reading from and
30
32
  # writing to Bigtable tables.
31
33
  #
32
34
  # @param project_id [String]
33
35
  # Project identifier for the Bigtable service you are connecting to.
34
36
  # If not present, the default project for the credentials is used.
35
- # @param credentials [Google::Auth::Credentials, String, Hash, GRPC::Core::Channel, GRPC::Core::ChannelCredentials, Proc]
37
+ # @param credentials [Google::Auth::Credentials, String, Hash, GRPC::Core::Channel,
38
+ # GRPC::Core::ChannelCredentials, Proc]
36
39
  # Provides the means for authenticating requests made by the client. This parameter can
37
40
  # be one of the following types:
38
41
  # `Google::Auth::Credentials` uses the properties of its represented keyfile for
@@ -70,14 +73,8 @@ module Google
70
73
  #
71
74
  # client = Google::Cloud::Bigtable.new
72
75
  #
73
- def self.new \
74
- project_id: nil,
75
- credentials: nil,
76
- emulator_host: nil,
77
- scope: nil,
78
- client_config: nil,
79
- endpoint: nil,
80
- timeout: nil
76
+ def self.new project_id: nil, credentials: nil, emulator_host: nil, scope: nil, client_config: nil, endpoint: nil,
77
+ timeout: nil
81
78
  project_id ||= default_project_id
82
79
  scope ||= configure.scope
83
80
  timeout ||= configure.timeout
@@ -98,9 +95,10 @@ module Google
98
95
  project_id, credentials,
99
96
  host: endpoint, timeout: timeout, client_config: client_config
100
97
  )
101
- Bigtable::Project.new(service)
98
+ Bigtable::Project.new service
102
99
  end
103
100
 
101
+ ##
104
102
  # Configure the Google Cloud Bigtable library.
105
103
  #
106
104
  # The following Bigtable configuration parameters are supported:
@@ -151,10 +149,8 @@ module Google
151
149
  #
152
150
  def self.resolve_credentials given_credentials, scope
153
151
  credentials = given_credentials || default_credentials(scope: scope)
154
- unless credentials.is_a? Google::Auth::Credentials
155
- credentials = Bigtable::Credentials.new credentials, scope: scope
156
- end
157
- credentials
152
+ return credentials if credentials.is_a? Google::Auth::Credentials
153
+ Bigtable::Credentials.new credentials, scope: scope
158
154
  end
159
155
 
160
156
  # @private
@@ -162,9 +158,7 @@ module Google
162
158
  #
163
159
  def self.resolve_project_id given_project_id, credentials
164
160
  project_id = given_project_id || default_project_id
165
- if credentials.respond_to? :project_id
166
- project_id ||= credentials.project_id
167
- end
161
+ project_id ||= credentials.project_id if credentials.respond_to? :project_id
168
162
  project_id.to_s # Always cast to a string
169
163
  end
170
164
 
@@ -17,10 +17,12 @@
17
17
 
18
18
  require "google/cloud/bigtable/app_profile/list"
19
19
  require "google/cloud/bigtable/app_profile/job"
20
+ require "google/cloud/bigtable/routing_policy"
20
21
 
21
22
  module Google
22
23
  module Cloud
23
24
  module Bigtable
25
+ ##
24
26
  # # AppProfile
25
27
  #
26
28
  # A configuration object describing how Cloud Bigtable should treat traffic
@@ -33,7 +35,7 @@ module Google
33
35
  #
34
36
  # instance = bigtable.instance("my-instance")
35
37
  #
36
- # app_profile = bigtable.app_profile("my-instance", "my-app-profile")
38
+ # app_profile = instance.app_profile("my-app-profile")
37
39
  #
38
40
  # # Update
39
41
  # app_profile.description = "User data instance app profile"
@@ -58,86 +60,113 @@ module Google
58
60
  @changed_fields = {}
59
61
  end
60
62
 
63
+ ##
61
64
  # The unique identifier for the project.
62
65
  #
63
66
  # @return [String]
67
+ #
64
68
  def project_id
65
69
  @grpc.name.split("/")[1]
66
70
  end
67
71
 
72
+ ##
68
73
  # The unique identifier for the instance.
69
74
  #
70
75
  # @return [String]
76
+ #
71
77
  def instance_id
72
78
  @grpc.name.split("/")[3]
73
79
  end
74
80
 
81
+ ##
75
82
  # The unique identifier for the app profile.
76
83
  #
77
84
  # @return [String]
85
+ #
78
86
  def name
79
87
  @grpc.name.split("/")[5]
80
88
  end
81
89
 
90
+ ##
82
91
  # The full path for the instance resource. Values are of the form
83
92
  # `projects/<project_id>/instances/<instance_id>`.
84
93
  #
85
94
  # @return [String]
95
+ #
86
96
  def path
87
97
  @grpc.name
88
98
  end
89
99
 
100
+ ##
90
101
  # Etag for optimistic concurrency control.
91
102
  #
92
103
  # @return [String]
104
+ #
93
105
  def etag
94
106
  @grpc.etag
95
107
  end
96
108
 
109
+ ##
97
110
  # Description of the AppProfile.
98
111
  #
99
112
  # @return [String]
113
+ #
100
114
  def description
101
115
  @grpc.description
102
116
  end
103
117
 
118
+ ##
104
119
  # Set description of the AppProfile.
105
120
  #
106
121
  # @param text [String] Description text
122
+ #
107
123
  def description= text
108
124
  @grpc.description = text
109
125
  @changed_fields["description"] = "description"
110
126
  end
111
127
 
112
- # Get value of multi-cluster routing policy.
128
+ ##
129
+ # Gets the multi-cluster routing policy, if present.
130
+ #
131
+ # @return [Google::Cloud::Bigtable::MultiClusterRoutingUseAny, nil]
113
132
  #
114
- # @return [Google::Bigtable::Admin::V2::AppProfile::MultiClusterRoutingUseAny]
115
133
  def multi_cluster_routing
116
- @grpc.multi_cluster_routing_use_any
134
+ return nil unless @grpc.multi_cluster_routing_use_any
135
+
136
+ Google::Cloud::Bigtable::MultiClusterRoutingUseAny.new
117
137
  end
118
138
 
119
- # Get value of single cluster routing policy.
139
+ ##
140
+ # Gets the single cluster routing policy, if present.
141
+ #
142
+ # @return [Google::Cloud::Bigtable::SingleClusterRouting, nil]
120
143
  #
121
- # @return [Google::Bigtable::Admin::V2::AppProfile::SingleClusterRouting]
122
144
  def single_cluster_routing
123
- @grpc.single_cluster_routing
145
+ return nil unless @grpc.single_cluster_routing
146
+
147
+ Google::Cloud::Bigtable::SingleClusterRouting.new(
148
+ @grpc.single_cluster_routing.cluster_id,
149
+ @grpc.single_cluster_routing.allow_transactional_writes
150
+ )
124
151
  end
125
152
 
126
- # Set routing policy.
153
+ ##
154
+ # Sets the routing policy for the app profile.
127
155
  #
128
- # @param policy [Google::Bigtable::Admin::V2::AppProfile::SingleClusterRouting | Google::Bigtable::Admin::V2::AppProfile::MultiClusterRoutingUseAny]
129
- # The routing policy for all read/write requests that use this app profile.
130
- # A value must be explicitly set.
156
+ # @param policy [Google::Cloud::Bigtable::RoutingPolicy]
157
+ # The routing policy for all read/write requests that use this app profile. A value must be explicitly set.
131
158
  #
132
159
  # Routing Policies:
133
- # * `multi_cluster_routing` - Read/write requests may be routed to any
134
- # cluster in the instance and will fail over to another cluster in the event
135
- # of transient errors or delays. Choosing this option sacrifices
136
- # read-your-writes consistency to improve availability.
137
- # * `single_cluster_routing` - Unconditionally routes all read/write requests
138
- # to a specific cluster. This option preserves read-your-writes consistency
139
- # but does not improve availability.
140
- # The value contains `cluster_id` and optional field `allow_transactional_writes`.
160
+ # * {Google::Cloud::Bigtable::MultiClusterRoutingUseAny} - Read/write
161
+ # requests may be routed to any cluster in the instance and will
162
+ # fail over to another cluster in the event of transient errors or
163
+ # delays. Choosing this option sacrifices read-your-writes
164
+ # consistency to improve availability.
165
+ # * {Google::Cloud::Bigtable::SingleClusterRouting} - Unconditionally
166
+ # routes all read/write requests to a specific cluster. This option
167
+ # preserves read-your-writes consistency but does not improve
168
+ # availability. Value contains `cluster_id` and optional field
169
+ # `allow_transactional_writes`.
141
170
  #
142
171
  # @example Set multi cluster routing policy
143
172
  # require "google/cloud/bigtable"
@@ -157,30 +186,61 @@ module Google
157
186
  # app_profile = instance.app_profile("my-app-profile")
158
187
  #
159
188
  # routing_policy = Google::Cloud::Bigtable::AppProfile.single_cluster_routing(
160
- # "my-instance-cluster-1"
189
+ # "my-instance-cluster-1",
161
190
  # allow_transactional_writes: true
162
191
  # )
163
192
  # app_profile.routing_policy = routing_policy
164
193
  #
165
194
  def routing_policy= policy
166
- if policy.is_a?(Google::Bigtable::Admin::V2::AppProfile:: \
167
- SingleClusterRouting)
168
- @grpc.single_cluster_routing = policy
195
+ routing_policy_grpc = policy.to_grpc
196
+ if routing_policy_grpc.is_a? Google::Bigtable::Admin::V2::AppProfile::SingleClusterRouting
197
+ @grpc.single_cluster_routing = routing_policy_grpc
169
198
  @changed_fields["routing_policy"] = "single_cluster_routing"
170
199
  else
171
- @grpc.multi_cluster_routing_use_any = policy
200
+ @grpc.multi_cluster_routing_use_any = routing_policy_grpc
172
201
  @changed_fields["routing_policy"] = "multi_cluster_routing_use_any"
173
202
  end
174
203
  end
175
204
 
176
- # Get routing policy.
205
+ ##
206
+ # Gets the routing policy for all read/write requests that use the app
207
+ # profile.
208
+ #
209
+ # Routing Policies:
210
+ # * {Google::Cloud::Bigtable::MultiClusterRoutingUseAny} - Read/write
211
+ # requests may be routed to any cluster in the instance and will
212
+ # fail over to another cluster in the event of transient errors or
213
+ # delays. Choosing this option sacrifices read-your-writes
214
+ # consistency to improve availability.
215
+ # * {Google::Cloud::Bigtable::SingleClusterRouting} - Unconditionally
216
+ # routes all read/write requests to a specific cluster. This option
217
+ # preserves read-your-writes consistency but does not improve
218
+ # availability. Value contains `cluster_id` and optional field
219
+ # `allow_transactional_writes`.
220
+ #
221
+ # @return [Google::Cloud::Bigtable::RoutingPolicy]
177
222
  #
178
- # @return [Google::Bigtable::Admin::V2::AppProfile::SingleClusterRouting, Google::Bigtable::Admin::V2::AppProfile::MultiClusterRoutingUseAny]
223
+ # @example
224
+ # require "google/cloud/bigtable"
225
+ #
226
+ # bigtable = Google::Cloud::Bigtable.new
227
+ #
228
+ # instance = bigtable.instance("my-instance")
229
+ #
230
+ # routing_policy = Google::Cloud::Bigtable::AppProfile.multi_cluster_routing
231
+ #
232
+ # app_profile = instance.create_app_profile(
233
+ # "my-app-profile",
234
+ # routing_policy,
235
+ # description: "App profile for user data instance"
236
+ # )
237
+ # puts app_profile.routing_policy
179
238
  #
180
239
  def routing_policy
181
- @grpc.single_cluster_routing || @grpc.multi_cluster_routing_use_any
240
+ single_cluster_routing || multi_cluster_routing
182
241
  end
183
242
 
243
+ ##
184
244
  # Delete app profile.
185
245
  #
186
246
  # @param ignore_warnings [Boolean]
@@ -194,7 +254,8 @@ module Google
194
254
  # bigtable = Google::Cloud::Bigtable.new
195
255
  #
196
256
  # instance = bigtable.instance("my-instance")
197
- # app_profile = bigtable.instance("my-app-profile")
257
+ #
258
+ # app_profile = instance.app_profile("my-app-profile")
198
259
  #
199
260
  # app_profile.delete(ignore_warnings: true) # Ignore warnings.
200
261
  #
@@ -203,14 +264,11 @@ module Google
203
264
  #
204
265
  def delete ignore_warnings: false
205
266
  ensure_service!
206
- service.delete_app_profile(
207
- instance_id,
208
- name,
209
- ignore_warnings: ignore_warnings
210
- )
267
+ service.delete_app_profile instance_id, name, ignore_warnings: ignore_warnings
211
268
  true
212
269
  end
213
270
 
271
+ ##
214
272
  # Update app profile.
215
273
  #
216
274
  # @param ignore_warnings [Boolean]
@@ -223,7 +281,9 @@ module Google
223
281
  #
224
282
  # bigtable = Google::Cloud::Bigtable.new
225
283
  #
226
- # app_profile = bigtable.app_profile("my-app-profile")
284
+ # instance = bigtable.instance("my-instance")
285
+ #
286
+ # app_profile = instance.app_profile("my-app-profile")
227
287
  #
228
288
  # app_profile.description = "User data instance app profile"
229
289
  # app_profile.routing_policy = \
@@ -238,17 +298,13 @@ module Google
238
298
  # app_profile = job.app_profile
239
299
  # end
240
300
  #
241
- # # OR - Update with ignoring warnings.
242
- # job = app_profile.save(ignore_warnings: true)
243
- # job.wait_until_done!
244
- #
245
301
  # @example Update with single cluster routing
246
302
  # require "google/cloud/bigtable"
247
303
  #
248
304
  # bigtable = Google::Cloud::Bigtable.new
249
305
  #
250
306
  # instance = bigtable.instance("my-instance")
251
- # app_profile = bigtable.instance("my-app-profile")
307
+ # app_profile = instance.app_profile("my-app-profile")
252
308
  #
253
309
  # app_profile.description = "User data instance app profile"
254
310
  # routing_policy = Google::Cloud::Bigtable::AppProfile.single_cluster_routing(
@@ -261,10 +317,6 @@ module Google
261
317
  #
262
318
  # job.done? #=> false
263
319
  # job.reload!
264
- # job.done? #=> false
265
- #
266
- # # Reload job until completion.
267
- # job.wait_until_done!
268
320
  # job.done? #=> true
269
321
  #
270
322
  # if job.error?
@@ -273,52 +325,62 @@ module Google
273
325
  # app_profile = job.app_profile
274
326
  # puts app_profile.name
275
327
  # end
276
-
328
+ #
277
329
  def save ignore_warnings: false
278
330
  ensure_service!
279
- update_mask = Google::Protobuf::FieldMask.new(
280
- paths: @changed_fields.values
281
- )
282
- grpc = service.update_app_profile(
283
- @grpc,
284
- update_mask,
285
- ignore_warnings: ignore_warnings
286
- )
331
+ update_mask = Google::Protobuf::FieldMask.new paths: @changed_fields.values
332
+ grpc = service.update_app_profile @grpc, update_mask, ignore_warnings: ignore_warnings
287
333
  @changed_fields.clear
288
- AppProfile::Job.from_grpc(grpc, service)
334
+ AppProfile::Job.from_grpc grpc, service
289
335
  end
290
336
  alias update save
291
337
 
338
+ ##
292
339
  # Reload app profile information.
293
340
  #
294
341
  # @return [Google::Cloud::Bigtable::AppProfile]
295
-
342
+ #
296
343
  def reload!
297
- @grpc = service.get_app_profile(instance_id, name)
344
+ @grpc = service.get_app_profile instance_id, name
298
345
  self
299
346
  end
300
347
 
301
- # Create instance of multi cluster routing policy.
348
+ ##
349
+ # Creates an instance of the multi cluster routing policy.
350
+ #
351
+ # Read/write requests may be routed to any cluster in the instance and
352
+ # will fail over to another cluster in the event of transient errors or
353
+ # delays. Choosing this option sacrifices read-your-writes consistency
354
+ # to improve availability.
302
355
  #
303
- # Read/write requests may be routed to any cluster in the instance and will
304
- # fail over to another cluster in the event of transient errors or delays.
305
- # Choosing this option sacrifices read-your-writes consistency to improve
306
- # availability.
307
- # @return [Google::Bigtable::Admin::V2::AppProfile::MultiClusterRoutingUseAny]
356
+ # @return [Google::Cloud::Bigtable::MultiClusterRoutingUseAny]
357
+ #
358
+ # @example
359
+ # require "google/cloud/bigtable"
308
360
  #
309
- # @example Create instance of multi cluster routing
361
+ # bigtable = Google::Cloud::Bigtable.new
310
362
  #
311
- # Google::Cloud::Bigtable::AppProfile.multi_cluster_routing
363
+ # instance = bigtable.instance("my-instance")
364
+ #
365
+ # routing_policy = Google::Cloud::Bigtable::AppProfile.multi_cluster_routing
366
+ #
367
+ # app_profile = instance.create_app_profile(
368
+ # "my-app-profile",
369
+ # routing_policy,
370
+ # description: "App profile for user data instance"
371
+ # )
372
+ # puts app_profile.routing_policy
312
373
  #
313
374
  def self.multi_cluster_routing
314
- Google::Bigtable::Admin::V2::AppProfile::MultiClusterRoutingUseAny.new
375
+ Google::Cloud::Bigtable::MultiClusterRoutingUseAny.new
315
376
  end
316
377
 
317
- # Create instance of single cluster routing.
378
+ ##
379
+ # Creates an instance of the single cluster routing policy.
318
380
  #
319
381
  # Unconditionally routes all read/write requests to a specific cluster.
320
- # This option preserves read-your-writes consistency but does not improve
321
- # availability.
382
+ # This option preserves read-your-writes consistency but does not
383
+ # improve availability.
322
384
  #
323
385
  # @param cluster_id [String]
324
386
  # The cluster to which read/write requests should be routed.
@@ -327,25 +389,29 @@ module Google
327
389
  # allowed by this app profile. It is unsafe to send these requests to
328
390
  # the same table/row/column in multiple clusters.
329
391
  # Default value is false.
330
- # @return [Google::Bigtable::Admin::V2::AppProfile::SingleClusterRouting]
392
+ # @return [Google::Cloud::Bigtable::SingleClusterRouting]
331
393
  #
332
- # @example Create instance of single cluster routing
394
+ # @example
395
+ # require "google/cloud/bigtable"
333
396
  #
334
- # Google::Cloud::Bigtable::AppProfile.single_cluster_routing("my-cluster")
397
+ # bigtable = Google::Cloud::Bigtable.new
335
398
  #
336
- # # With allowed transactional writes
337
- # Google::Cloud::Bigtable::AppProfile.single_cluster_routing(
338
- # "my-cluster",
399
+ # instance = bigtable.instance("my-instance")
400
+ #
401
+ # routing_policy = Google::Cloud::Bigtable::AppProfile.single_cluster_routing(
402
+ # "my-instance-cluster-1",
339
403
  # allow_transactional_writes: true
340
404
  # )
341
-
342
- def self.single_cluster_routing \
343
- cluster_id,
344
- allow_transactional_writes: false
345
- Google::Bigtable::Admin::V2::AppProfile::SingleClusterRouting.new(
346
- cluster_id: cluster_id,
347
- allow_transactional_writes: allow_transactional_writes
348
- )
405
+ #
406
+ # app_profile = instance.create_app_profile(
407
+ # "my-app-profile",
408
+ # routing_policy,
409
+ # description: "App profile for user data instance"
410
+ # )
411
+ # puts app_profile.routing_policy
412
+ #
413
+ def self.single_cluster_routing cluster_id, allow_transactional_writes: false
414
+ Google::Cloud::Bigtable::SingleClusterRouting.new cluster_id, allow_transactional_writes
349
415
  end
350
416
 
351
417
  # @private
@@ -356,7 +422,7 @@ module Google
356
422
  # @param service [Google::Cloud::Bigtable::Service]
357
423
  # @return [Google::Cloud::Bigtable::Table]
358
424
  def self.from_grpc grpc, service
359
- new(grpc, service)
425
+ new grpc, service
360
426
  end
361
427
 
362
428
  protected