google-cloud-bigtable 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (103) hide show
  1. checksums.yaml +7 -0
  2. data/.yardopts +19 -0
  3. data/AUTHENTICATION.md +177 -0
  4. data/CHANGELOG.md +223 -0
  5. data/CODE_OF_CONDUCT.md +40 -0
  6. data/CONTRIBUTING.md +188 -0
  7. data/EMULATOR.md +30 -0
  8. data/LICENSE +201 -0
  9. data/LOGGING.md +32 -0
  10. data/OVERVIEW.md +400 -0
  11. data/TROUBLESHOOTING.md +31 -0
  12. data/lib/google-cloud-bigtable.rb +171 -0
  13. data/lib/google/bigtable/admin/v2/bigtable_instance_admin_pb.rb +145 -0
  14. data/lib/google/bigtable/admin/v2/bigtable_instance_admin_services_pb.rb +90 -0
  15. data/lib/google/bigtable/admin/v2/bigtable_table_admin_pb.rb +208 -0
  16. data/lib/google/bigtable/admin/v2/bigtable_table_admin_services_pb.rb +154 -0
  17. data/lib/google/bigtable/admin/v2/common_pb.rb +30 -0
  18. data/lib/google/bigtable/admin/v2/instance_pb.rb +74 -0
  19. data/lib/google/bigtable/admin/v2/table_pb.rb +127 -0
  20. data/lib/google/bigtable/v2/bigtable_pb.rb +113 -0
  21. data/lib/google/bigtable/v2/bigtable_services_pb.rb +68 -0
  22. data/lib/google/bigtable/v2/data_pb.rb +156 -0
  23. data/lib/google/cloud/bigtable.rb +184 -0
  24. data/lib/google/cloud/bigtable/admin.rb +202 -0
  25. data/lib/google/cloud/bigtable/admin/credentials.rb +27 -0
  26. data/lib/google/cloud/bigtable/admin/v2.rb +223 -0
  27. data/lib/google/cloud/bigtable/admin/v2/bigtable_instance_admin_client.rb +1451 -0
  28. data/lib/google/cloud/bigtable/admin/v2/bigtable_instance_admin_client_config.json +139 -0
  29. data/lib/google/cloud/bigtable/admin/v2/bigtable_table_admin_client.rb +1734 -0
  30. data/lib/google/cloud/bigtable/admin/v2/bigtable_table_admin_client_config.json +163 -0
  31. data/lib/google/cloud/bigtable/admin/v2/credentials.rb +51 -0
  32. data/lib/google/cloud/bigtable/admin/v2/doc/google/bigtable/admin/v2/bigtable_instance_admin.rb +297 -0
  33. data/lib/google/cloud/bigtable/admin/v2/doc/google/bigtable/admin/v2/bigtable_table_admin.rb +587 -0
  34. data/lib/google/cloud/bigtable/admin/v2/doc/google/bigtable/admin/v2/instance.rb +193 -0
  35. data/lib/google/cloud/bigtable/admin/v2/doc/google/bigtable/admin/v2/table.rb +303 -0
  36. data/lib/google/cloud/bigtable/admin/v2/doc/google/iam/v1/iam_policy.rb +64 -0
  37. data/lib/google/cloud/bigtable/admin/v2/doc/google/iam/v1/options.rb +33 -0
  38. data/lib/google/cloud/bigtable/admin/v2/doc/google/iam/v1/policy.rb +151 -0
  39. data/lib/google/cloud/bigtable/admin/v2/doc/google/longrunning/operations.rb +51 -0
  40. data/lib/google/cloud/bigtable/admin/v2/doc/google/protobuf/any.rb +131 -0
  41. data/lib/google/cloud/bigtable/admin/v2/doc/google/protobuf/duration.rb +91 -0
  42. data/lib/google/cloud/bigtable/admin/v2/doc/google/protobuf/empty.rb +29 -0
  43. data/lib/google/cloud/bigtable/admin/v2/doc/google/protobuf/field_mask.rb +222 -0
  44. data/lib/google/cloud/bigtable/admin/v2/doc/google/protobuf/timestamp.rb +113 -0
  45. data/lib/google/cloud/bigtable/admin/v2/doc/google/rpc/status.rb +39 -0
  46. data/lib/google/cloud/bigtable/admin/v2/doc/google/type/expr.rb +45 -0
  47. data/lib/google/cloud/bigtable/app_profile.rb +439 -0
  48. data/lib/google/cloud/bigtable/app_profile/job.rb +99 -0
  49. data/lib/google/cloud/bigtable/app_profile/list.rb +165 -0
  50. data/lib/google/cloud/bigtable/backup.rb +324 -0
  51. data/lib/google/cloud/bigtable/backup/job.rb +87 -0
  52. data/lib/google/cloud/bigtable/backup/list.rb +167 -0
  53. data/lib/google/cloud/bigtable/chunk_processor.rb +241 -0
  54. data/lib/google/cloud/bigtable/cluster.rb +390 -0
  55. data/lib/google/cloud/bigtable/cluster/job.rb +88 -0
  56. data/lib/google/cloud/bigtable/cluster/list.rb +171 -0
  57. data/lib/google/cloud/bigtable/column_family.rb +73 -0
  58. data/lib/google/cloud/bigtable/column_family_map.rb +426 -0
  59. data/lib/google/cloud/bigtable/column_range.rb +194 -0
  60. data/lib/google/cloud/bigtable/convert.rb +83 -0
  61. data/lib/google/cloud/bigtable/credentials.rb +25 -0
  62. data/lib/google/cloud/bigtable/errors.rb +38 -0
  63. data/lib/google/cloud/bigtable/gc_rule.rb +334 -0
  64. data/lib/google/cloud/bigtable/instance.rb +935 -0
  65. data/lib/google/cloud/bigtable/instance/cluster_map.rb +74 -0
  66. data/lib/google/cloud/bigtable/instance/job.rb +98 -0
  67. data/lib/google/cloud/bigtable/instance/list.rb +164 -0
  68. data/lib/google/cloud/bigtable/longrunning_job.rb +122 -0
  69. data/lib/google/cloud/bigtable/mutation_entry.rb +256 -0
  70. data/lib/google/cloud/bigtable/mutation_operations.rb +357 -0
  71. data/lib/google/cloud/bigtable/policy.rb +167 -0
  72. data/lib/google/cloud/bigtable/project.rb +471 -0
  73. data/lib/google/cloud/bigtable/read_modify_write_rule.rb +134 -0
  74. data/lib/google/cloud/bigtable/read_operations.rb +328 -0
  75. data/lib/google/cloud/bigtable/routing_policy.rb +172 -0
  76. data/lib/google/cloud/bigtable/row.rb +136 -0
  77. data/lib/google/cloud/bigtable/row_filter.rb +639 -0
  78. data/lib/google/cloud/bigtable/row_filter/chain_filter.rb +590 -0
  79. data/lib/google/cloud/bigtable/row_filter/condition_filter.rb +114 -0
  80. data/lib/google/cloud/bigtable/row_filter/interleave_filter.rb +621 -0
  81. data/lib/google/cloud/bigtable/row_filter/simple_filter.rb +287 -0
  82. data/lib/google/cloud/bigtable/row_range.rb +179 -0
  83. data/lib/google/cloud/bigtable/rows_mutator.rb +113 -0
  84. data/lib/google/cloud/bigtable/rows_reader.rb +200 -0
  85. data/lib/google/cloud/bigtable/sample_row_key.rb +85 -0
  86. data/lib/google/cloud/bigtable/service.rb +913 -0
  87. data/lib/google/cloud/bigtable/status.rb +76 -0
  88. data/lib/google/cloud/bigtable/table.rb +686 -0
  89. data/lib/google/cloud/bigtable/table/cluster_state.rb +125 -0
  90. data/lib/google/cloud/bigtable/table/list.rb +154 -0
  91. data/lib/google/cloud/bigtable/table/restore_job.rb +117 -0
  92. data/lib/google/cloud/bigtable/v2.rb +146 -0
  93. data/lib/google/cloud/bigtable/v2/bigtable_client.rb +591 -0
  94. data/lib/google/cloud/bigtable/v2/bigtable_client_config.json +83 -0
  95. data/lib/google/cloud/bigtable/v2/credentials.rb +46 -0
  96. data/lib/google/cloud/bigtable/v2/doc/google/bigtable/v2/bigtable.rb +290 -0
  97. data/lib/google/cloud/bigtable/v2/doc/google/bigtable/v2/data.rb +493 -0
  98. data/lib/google/cloud/bigtable/v2/doc/google/protobuf/any.rb +131 -0
  99. data/lib/google/cloud/bigtable/v2/doc/google/protobuf/wrappers.rb +34 -0
  100. data/lib/google/cloud/bigtable/v2/doc/google/rpc/status.rb +39 -0
  101. data/lib/google/cloud/bigtable/value_range.rb +181 -0
  102. data/lib/google/cloud/bigtable/version.rb +22 -0
  103. metadata +337 -0
@@ -0,0 +1,439 @@
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
+ require "google/cloud/bigtable/app_profile/list"
19
+ require "google/cloud/bigtable/app_profile/job"
20
+ require "google/cloud/bigtable/routing_policy"
21
+
22
+ module Google
23
+ module Cloud
24
+ module Bigtable
25
+ ##
26
+ # # AppProfile
27
+ #
28
+ # A configuration object describing how Cloud Bigtable should treat traffic
29
+ # from a particular end user application.
30
+ #
31
+ # @example
32
+ # require "google/cloud/bigtable"
33
+ #
34
+ # bigtable = Google::Cloud::Bigtable.new
35
+ #
36
+ # instance = bigtable.instance("my-instance")
37
+ #
38
+ # app_profile = instance.app_profile("my-app-profile")
39
+ #
40
+ # # Update
41
+ # app_profile.description = "User data instance app profile"
42
+ # app_profile.routing_policy = Google::Cloud::Bigtable::AppProfile.multi_cluster_routing
43
+ # job = app_profile.save
44
+ # job.wait_until_done!
45
+ #
46
+ # # Delete
47
+ # app_profile.delete
48
+ #
49
+ class AppProfile
50
+ # @private
51
+ # The gRPC Service object.
52
+ attr_accessor :service
53
+
54
+ # @private
55
+ #
56
+ # Creates a new AppProfile instance.
57
+ def initialize grpc, service
58
+ @grpc = grpc
59
+ @service = service
60
+ @changed_fields = {}
61
+ end
62
+
63
+ ##
64
+ # The unique identifier for the project to which the app profile belongs.
65
+ #
66
+ # @return [String]
67
+ #
68
+ def project_id
69
+ @grpc.name.split("/")[1]
70
+ end
71
+
72
+ ##
73
+ # The unique identifier for the instance to which the app profile belongs.
74
+ #
75
+ # @return [String]
76
+ #
77
+ def instance_id
78
+ @grpc.name.split("/")[3]
79
+ end
80
+
81
+ ##
82
+ # The unique identifier for the app profile.
83
+ #
84
+ # @return [String]
85
+ #
86
+ def name
87
+ @grpc.name.split("/")[5]
88
+ end
89
+
90
+ ##
91
+ # The full path for the app profile resource. Values are of the form:
92
+ # `projects/<project_id>/instances/<instance_id>/appProfiles/<app_profile_name>`.
93
+ #
94
+ # @return [String]
95
+ #
96
+ def path
97
+ @grpc.name
98
+ end
99
+
100
+ ##
101
+ # Etag for optimistic concurrency control.
102
+ #
103
+ # @return [String]
104
+ #
105
+ def etag
106
+ @grpc.etag
107
+ end
108
+
109
+ ##
110
+ # Description of the app profile.
111
+ #
112
+ # @return [String]
113
+ #
114
+ def description
115
+ @grpc.description
116
+ end
117
+
118
+ ##
119
+ # Sets the description of the app profile.
120
+ #
121
+ # @param text [String] Description text
122
+ #
123
+ def description= text
124
+ @grpc.description = text
125
+ @changed_fields["description"] = "description"
126
+ end
127
+
128
+ ##
129
+ # Gets the multi-cluster routing policy, if present.
130
+ #
131
+ # @return [Google::Cloud::Bigtable::MultiClusterRoutingUseAny, nil]
132
+ #
133
+ def multi_cluster_routing
134
+ return nil unless @grpc.multi_cluster_routing_use_any
135
+
136
+ Google::Cloud::Bigtable::MultiClusterRoutingUseAny.new
137
+ end
138
+
139
+ ##
140
+ # Gets the single cluster routing policy, if present.
141
+ #
142
+ # @return [Google::Cloud::Bigtable::SingleClusterRouting, nil]
143
+ #
144
+ def 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
+ )
151
+ end
152
+
153
+ ##
154
+ # Sets the routing policy for the app profile.
155
+ #
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.
158
+ #
159
+ # Routing Policies:
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`.
170
+ #
171
+ # @example Set multi cluster routing policy.
172
+ # require "google/cloud/bigtable"
173
+ #
174
+ # bigtable = Google::Cloud::Bigtable.new
175
+ # instance = bigtable.instance("my-instance")
176
+ # app_profile = instance.app_profile("my-app-profile")
177
+ #
178
+ # routing_policy = Google::Cloud::Bigtable::AppProfile.multi_cluster_routing
179
+ # app_profile.routing_policy = routing_policy
180
+ #
181
+ # @example Set single cluster routing policy.
182
+ # require "google/cloud/bigtable"
183
+ #
184
+ # bigtable = Google::Cloud::Bigtable.new
185
+ # instance = bigtable.instance("my-instance")
186
+ # app_profile = instance.app_profile("my-app-profile")
187
+ #
188
+ # routing_policy = Google::Cloud::Bigtable::AppProfile.single_cluster_routing(
189
+ # "my-instance-cluster-1",
190
+ # allow_transactional_writes: true
191
+ # )
192
+ # app_profile.routing_policy = routing_policy
193
+ #
194
+ def routing_policy= 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
198
+ @changed_fields["routing_policy"] = "single_cluster_routing"
199
+ else
200
+ @grpc.multi_cluster_routing_use_any = routing_policy_grpc
201
+ @changed_fields["routing_policy"] = "multi_cluster_routing_use_any"
202
+ end
203
+ end
204
+
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]
222
+ #
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
238
+ #
239
+ def routing_policy
240
+ single_cluster_routing || multi_cluster_routing
241
+ end
242
+
243
+ ##
244
+ # Deletes the app profile.
245
+ #
246
+ # @param ignore_warnings [Boolean]
247
+ # Default value is false. If true, ignore safety checks when deleting
248
+ # the app profile.
249
+ # @return [Boolean] Returns `true` if the app profile was deleted.
250
+ #
251
+ # @example
252
+ # require "google/cloud/bigtable"
253
+ #
254
+ # bigtable = Google::Cloud::Bigtable.new
255
+ #
256
+ # instance = bigtable.instance("my-instance")
257
+ #
258
+ # app_profile = instance.app_profile("my-app-profile")
259
+ #
260
+ # app_profile.delete(ignore_warnings: true) # Ignore warnings.
261
+ #
262
+ # # OR : Not ignoring warnings
263
+ # app_profile.delete
264
+ #
265
+ def delete ignore_warnings: false
266
+ ensure_service!
267
+ service.delete_app_profile instance_id, name, ignore_warnings: ignore_warnings
268
+ true
269
+ end
270
+
271
+ ##
272
+ # Updates the app profile.
273
+ #
274
+ # @param ignore_warnings [Boolean]
275
+ # Default value is false. If true, ignore safety checks when updating
276
+ # the app profile.
277
+ # @return [Google::Cloud::Bigtable::AppProfile::Job]
278
+ #
279
+ # @example
280
+ # require "google/cloud/bigtable"
281
+ #
282
+ # bigtable = Google::Cloud::Bigtable.new
283
+ #
284
+ # instance = bigtable.instance("my-instance")
285
+ #
286
+ # app_profile = instance.app_profile("my-app-profile")
287
+ #
288
+ # app_profile.description = "User data instance app profile"
289
+ # app_profile.routing_policy = \
290
+ # Google::Cloud::Bigtable::AppProfile.multi_cluster_routing
291
+ #
292
+ # job = app_profile.save
293
+ # job.wait_until_done!
294
+ # if job.error?
295
+ # puts job.error
296
+ # else
297
+ # puts "App profile successfully update."
298
+ # app_profile = job.app_profile
299
+ # end
300
+ #
301
+ # @example Update with single cluster routing.
302
+ # require "google/cloud/bigtable"
303
+ #
304
+ # bigtable = Google::Cloud::Bigtable.new
305
+ #
306
+ # instance = bigtable.instance("my-instance")
307
+ # app_profile = instance.app_profile("my-app-profile")
308
+ #
309
+ # app_profile.description = "User data instance app profile"
310
+ # routing_policy = Google::Cloud::Bigtable::AppProfile.single_cluster_routing(
311
+ # "my-cluster",
312
+ # allow_transactional_writes: true
313
+ # )
314
+ # app_profile.routing_policy = routing_policy
315
+ #
316
+ # job = app_profile.save
317
+ #
318
+ # job.done? #=> false
319
+ # job.reload!
320
+ # job.done? #=> true
321
+ #
322
+ # if job.error?
323
+ # puts job.error
324
+ # else
325
+ # app_profile = job.app_profile
326
+ # puts app_profile.name
327
+ # end
328
+ #
329
+ def save ignore_warnings: false
330
+ ensure_service!
331
+ update_mask = Google::Protobuf::FieldMask.new paths: @changed_fields.values
332
+ grpc = service.update_app_profile @grpc, update_mask, ignore_warnings: ignore_warnings
333
+ @changed_fields.clear
334
+ AppProfile::Job.from_grpc grpc, service
335
+ end
336
+ alias update save
337
+
338
+ ##
339
+ # Reloads the app profile data.
340
+ #
341
+ # @return [Google::Cloud::Bigtable::AppProfile]
342
+ #
343
+ def reload!
344
+ @grpc = service.get_app_profile instance_id, name
345
+ self
346
+ end
347
+
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.
355
+ #
356
+ # @return [Google::Cloud::Bigtable::MultiClusterRoutingUseAny]
357
+ #
358
+ # @example
359
+ # require "google/cloud/bigtable"
360
+ #
361
+ # bigtable = Google::Cloud::Bigtable.new
362
+ #
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
373
+ #
374
+ def self.multi_cluster_routing
375
+ Google::Cloud::Bigtable::MultiClusterRoutingUseAny.new
376
+ end
377
+
378
+ ##
379
+ # Creates an instance of the single cluster routing policy.
380
+ #
381
+ # Unconditionally routes all read/write requests to a specific cluster.
382
+ # This option preserves read-your-writes consistency but does not
383
+ # improve availability.
384
+ #
385
+ # @param cluster_id [String]
386
+ # The cluster to which read/write requests should be routed.
387
+ # @param allow_transactional_writes [Boolean]
388
+ # If true, `CheckAndMutateRow` and `ReadModifyWriteRow` requests are
389
+ # allowed by this app profile. It is unsafe to send these requests to
390
+ # the same table/row/column in multiple clusters.
391
+ # Default value is false.
392
+ # @return [Google::Cloud::Bigtable::SingleClusterRouting]
393
+ #
394
+ # @example
395
+ # require "google/cloud/bigtable"
396
+ #
397
+ # bigtable = Google::Cloud::Bigtable.new
398
+ #
399
+ # instance = bigtable.instance("my-instance")
400
+ #
401
+ # routing_policy = Google::Cloud::Bigtable::AppProfile.single_cluster_routing(
402
+ # "my-instance-cluster-1",
403
+ # allow_transactional_writes: true
404
+ # )
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
415
+ end
416
+
417
+ # @private
418
+ #
419
+ # Creates a new Instance instance from a
420
+ # Google::Bigtable::Admin::V2::Table.
421
+ # @param grpc [Google::Bigtable::Admin::V2::Table]
422
+ # @param service [Google::Cloud::Bigtable::Service]
423
+ # @return [Google::Cloud::Bigtable::Table]
424
+ def self.from_grpc grpc, service
425
+ new grpc, service
426
+ end
427
+
428
+ protected
429
+
430
+ # @private
431
+ # Raise an error unless an active connection to the service is
432
+ # available.
433
+ def ensure_service!
434
+ raise "Must have active connection to service" unless service
435
+ end
436
+ end
437
+ end
438
+ end
439
+ end
@@ -0,0 +1,99 @@
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
+ ##
21
+ # # Job
22
+ #
23
+ # A resource representing the long-running, asynchronous processing of
24
+ # an app profile create or update operation. The job can be refreshed to
25
+ # retrieve the app profile object once the operation has been completed.
26
+ #
27
+ # See {AppProfile#save}.
28
+ #
29
+ # @see https://cloud.google.com/bigtable/docs/reference/admin/rpc/google.longrunning#google.longrunning.Operation
30
+ # Long-running Operation
31
+ #
32
+ # @example
33
+ # require "google/cloud/bigtable"
34
+ #
35
+ # bigtable = Google::Cloud::Bigtable.new
36
+ #
37
+ # instance = bigtable.instance("my-instance")
38
+ # app_profile = instance.app_profile("my-app-profile")
39
+ #
40
+ # app_profile.description = "User data instance app profile"
41
+ # routing_policy = Google::Cloud::Bigtable::AppProfile.single_cluster_routing(
42
+ # "my-cluster",
43
+ # allow_transactional_writes: true
44
+ # )
45
+ # app_profile.routing_policy = routing_policy
46
+ #
47
+ # job = app_profile.save
48
+ #
49
+ # job.done? #=> false
50
+ # job.reload! # API call
51
+ # job.done? #=> true
52
+ #
53
+ # # OR
54
+ # job.wait_until_done!
55
+ #
56
+ # if job.error?
57
+ # status = job.error
58
+ # else
59
+ # app_profile = job.app_profile
60
+ # end
61
+ #
62
+ class Job < LongrunningJob
63
+ ##
64
+ # The instance that is the object of the operation.
65
+ #
66
+ # @return [Google::Cloud::Bigtable::AppProfile, nil] The app profile instance, or
67
+ # `nil` if the operation is not complete.
68
+ #
69
+ # @example
70
+ # require "google/cloud/bigtable"
71
+ #
72
+ # bigtable = Google::Cloud::Bigtable.new
73
+ #
74
+ # instance = bigtable.instance("my-instance")
75
+ # app_profile = instance.app_profile("my-app-profile")
76
+ #
77
+ # app_profile.description = "User data instance app profile"
78
+ # routing_policy = Google::Cloud::Bigtable::AppProfile.single_cluster_routing(
79
+ # "my-cluster",
80
+ # allow_transactional_writes: true
81
+ # )
82
+ # app_profile.routing_policy = routing_policy
83
+ #
84
+ # job = app_profile.save
85
+ #
86
+ # job.wait_until_done!
87
+ #
88
+ # app_profile = job.app_profile
89
+ #
90
+ def app_profile
91
+ return nil unless done?
92
+ return nil unless @grpc.grpc_op.result == :response
93
+ AppProfile.from_grpc @grpc.results, service
94
+ end
95
+ end
96
+ end
97
+ end
98
+ end
99
+ end