google-cloud-bigtable 1.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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,400 @@
1
+ # Cloud Bigtable
2
+
3
+ Cloud Bigtable is a petabyte-scale, fully managed NoSQL database service for
4
+ large analytical and operational workloads. Ideal for ad tech, fintech, and IoT,
5
+ Cloud Bigtable offers consistent sub-10ms latency. Replication provides higher
6
+ availability, higher durability, and resilience in the face of zonal failures.
7
+ Cloud Bigtable is designed with a storage engine for machine learning
8
+ applications and provides easy integration with open source big data tools.
9
+
10
+ For more information about Cloud Bigtable, read the [Cloud Bigtable
11
+ Documentation](https://cloud.google.com/bigtable/docs/).
12
+
13
+ The goal of google-cloud is to provide an API that is comfortable to Rubyists.
14
+ Your authentication credentials are detected automatically in Google Cloud
15
+ Platform (GCP), including Google Compute Engine (GCE), Google Kubernetes Engine
16
+ (GKE), Google App Engine (GAE), Google Cloud Functions (GCF) and Cloud Run. In
17
+ other environments you can configure authentication easily, either directly in
18
+ your code or via environment variables. Read more about the options for
19
+ connecting in the {file:AUTHENTICATION.md Authentication Guide}.
20
+
21
+ ## Creating instances and clusters
22
+
23
+ When you first use Cloud Bigtable, you must create an instance, which is an
24
+ allocation of resources that are used by Cloud Bigtable. When you create an
25
+ instance, you must specify at least one cluster. Clusters describe where your
26
+ data is stored and how many nodes are used for your data.
27
+
28
+ Use {Google::Cloud::Bigtable::Project#create_instance Project#create_instance}
29
+ to create an instance. The following example creates a production instance with
30
+ one cluster and three nodes:
31
+
32
+ ```ruby
33
+ require "google/cloud/bigtable"
34
+
35
+ bigtable = Google::Cloud::Bigtable.new
36
+
37
+ job = bigtable.create_instance(
38
+ "my-instance",
39
+ display_name: "Instance for user data",
40
+ labels: { "env" => "dev"}
41
+ ) do |clusters|
42
+ clusters.add("test-cluster", "us-east1-b", nodes: 3, storage_type: :SSD)
43
+ end
44
+
45
+ job.done? #=> false
46
+
47
+ # To block until the operation completes.
48
+ job.wait_until_done!
49
+ job.done? #=> true
50
+
51
+ if job.error?
52
+ status = job.error
53
+ else
54
+ instance = job.instance
55
+ end
56
+ ```
57
+
58
+ You can also create a low-cost development instance for development and testing,
59
+ with performance limited to the equivalent of a one-node cluster. There are no
60
+ monitoring or throughput guarantees; replication is not available; and the SLA
61
+ does not apply. When creating a development instance, you do not specify `nodes`
62
+ for your clusters:
63
+
64
+ ```ruby
65
+ require "google/cloud/bigtable"
66
+
67
+ bigtable = Google::Cloud::Bigtable.new
68
+
69
+ job = bigtable.create_instance(
70
+ "my-instance",
71
+ display_name: "Instance for user data",
72
+ type: :DEVELOPMENT,
73
+ labels: { "env" => "dev"}
74
+ ) do |clusters|
75
+ clusters.add("test-cluster", "us-east1-b") # nodes not allowed
76
+ end
77
+
78
+ job.done? #=> false
79
+
80
+ # Reload job until completion.
81
+ job.wait_until_done!
82
+ job.done? #=> true
83
+
84
+ if job.error?
85
+ status = job.error
86
+ else
87
+ instance = job.instance
88
+ end
89
+ ```
90
+
91
+ You can upgrade a development instance to a production instance at any time.
92
+
93
+ ## Creating tables
94
+
95
+ Cloud Bigtable stores data in massively scalable tables, each of which is a
96
+ sorted key/value map. The table is composed of rows, each of which typically
97
+ describes a single entity, and columns, which contain individual values for each
98
+ row. Each row is indexed by a single row key, and columns that are related to
99
+ one another are typically grouped together into a column family. Each column is
100
+ identified by a combination of the column family and a column qualifier, which
101
+ is a unique name within the column family.
102
+
103
+ Each row/column intersection can contain multiple cells, or versions, at
104
+ different timestamps, providing a record of how the stored data has been altered
105
+ over time. Cloud Bigtable tables are sparse; if a cell does not contain any
106
+ data, it does not take up any space.
107
+
108
+ Use {Google::Cloud::Bigtable::Project#create_table Project#create_table} or
109
+ {Google::Cloud::Bigtable::Instance#create_table Instance#create_table} to
110
+ create a table:
111
+
112
+ ```ruby
113
+ require "google/cloud/bigtable"
114
+
115
+ bigtable = Google::Cloud::Bigtable.new
116
+
117
+ table = bigtable.create_table("my-instance", "my-table")
118
+ puts table.name
119
+ ```
120
+
121
+ When you create a table, you may specify the column families to use in the
122
+ table, as well as a list of row keys that will be used to initially split the
123
+ table into several tablets (tablets are similar to HBase regions):
124
+
125
+ ```ruby
126
+ require "google/cloud/bigtable"
127
+
128
+ bigtable = Google::Cloud::Bigtable.new
129
+
130
+ initial_splits = ["user-00001", "user-100000", "others"]
131
+ table = bigtable.create_table("my-instance", "my-table", initial_splits: initial_splits) do |cfm|
132
+ cfm.add('cf1', gc_rule: Google::Cloud::Bigtable::GcRule.max_versions(5))
133
+ cfm.add('cf2', gc_rule: Google::Cloud::Bigtable::GcRule.max_age(600))
134
+
135
+ gc_rule = Google::Cloud::Bigtable::GcRule.union(
136
+ Google::Cloud::Bigtable::GcRule.max_age(1800),
137
+ Google::Cloud::Bigtable::GcRule.max_versions(3)
138
+ )
139
+ cfm.add('cf3', gc_rule: gc_rule)
140
+ end
141
+
142
+ puts table
143
+ ```
144
+
145
+ You may also add, update, and delete column families later by passing a block to
146
+ {Google::Cloud::Bigtable::Table#column_families Table#column_families}:
147
+
148
+ ```ruby
149
+ require "google/cloud/bigtable"
150
+
151
+ bigtable = Google::Cloud::Bigtable.new
152
+
153
+ table = bigtable.table("my-instance", "my-table", perform_lookup: true)
154
+
155
+ table.column_families do |cfm|
156
+ cfm.add "cf4", gc_rule: Google::Cloud::Bigtable::GcRule.max_age(600)
157
+ cfm.add "cf5", gc_rule: Google::Cloud::Bigtable::GcRule.max_versions(5)
158
+
159
+ rule_1 = Google::Cloud::Bigtable::GcRule.max_versions(3)
160
+ rule_2 = Google::Cloud::Bigtable::GcRule.max_age(600)
161
+ rule_union = Google::Cloud::Bigtable::GcRule.union(rule_1, rule_2)
162
+ cfm.update "cf2", gc_rule: rule_union
163
+
164
+ cfm.delete "cf3"
165
+ end
166
+
167
+ puts table.column_families["cf3"] #=> nil
168
+ ```
169
+
170
+ ## Writing data
171
+
172
+ The {Google::Cloud::Bigtable::Table Table} class allows you to perform the
173
+ following types of writes:
174
+
175
+ * Simple writes
176
+ * Increments and appends
177
+ * Conditional writes
178
+ * Batch writes
179
+
180
+ See [Cloud Bigtable writes](https://cloud.google.com/bigtable/docs/writes) for
181
+ detailed information about writing data.
182
+
183
+ ### Simple writes
184
+
185
+ Use {Google::Cloud::Bigtable::Table#mutate_row Table#mutate_row} to make
186
+ one or more mutations to a single row:
187
+
188
+ ```ruby
189
+ require "google/cloud/bigtable"
190
+
191
+ bigtable = Google::Cloud::Bigtable.new
192
+
193
+ table = bigtable.table("my-instance", "my-table")
194
+
195
+ entry = table.new_mutation_entry("user-1")
196
+ entry.set_cell(
197
+ "cf-1",
198
+ "field-1",
199
+ "XYZ",
200
+ timestamp: (Time.now.to_f * 1000000).round(-3) # microseconds
201
+ ).delete_cells("cf2", "field02")
202
+
203
+ table.mutate_row(entry)
204
+ ```
205
+
206
+ ### Increments and appends
207
+
208
+ If you want to append data to an existing value or increment an existing numeric
209
+ value, use
210
+ {Google::Cloud::Bigtable::Table#read_modify_write_row Table#read_modify_write_row}:
211
+
212
+ ```ruby
213
+ require "google/cloud/bigtable"
214
+
215
+ bigtable = Google::Cloud::Bigtable.new
216
+ table = bigtable.table("my-instance", "my-table")
217
+
218
+ rule_1 = table.new_read_modify_write_rule("cf", "field01")
219
+ rule_1.append("append-xyz")
220
+
221
+ rule_2 = table.new_read_modify_write_rule("cf", "field01")
222
+ rule_2.increment(1)
223
+
224
+ row = table.read_modify_write_row("user01", [rule_1, rule_2])
225
+
226
+ puts row.cells
227
+ ```
228
+
229
+ Do not use `read_modify_write_row` if you are using an app profile that has
230
+ multi-cluster routing. (See
231
+ {Google::Cloud::Bigtable::AppProfile#routing_policy AppProfile#routing_policy}.)
232
+
233
+ ### Conditional writes
234
+
235
+ To check a row for a condition and then, depending on the result, write data to
236
+ that row, use
237
+ {Google::Cloud::Bigtable::Table#check_and_mutate_row Table#check_and_mutate_row}:
238
+
239
+ ```ruby
240
+ require "google/cloud/bigtable"
241
+
242
+ bigtable = Google::Cloud::Bigtable.new
243
+ table = bigtable.table("my-instance", "my-table")
244
+
245
+ predicate_filter = Google::Cloud::Bigtable::RowFilter.key("user-10")
246
+ on_match_mutations = Google::Cloud::Bigtable::MutationEntry.new
247
+ on_match_mutations.set_cell(
248
+ "cf-1",
249
+ "field-1",
250
+ "XYZ",
251
+ timestamp: (Time.now.to_f * 1000000).round(-3) # microseconds
252
+ ).delete_cells("cf2", "field02")
253
+
254
+ otherwise_mutations = Google::Cloud::Bigtable::MutationEntry.new
255
+ otherwise_mutations.delete_from_family("cf3")
256
+
257
+ predicate_matched = table.check_and_mutate_row(
258
+ "user01",
259
+ predicate_filter,
260
+ on_match: on_match_mutations,
261
+ otherwise: otherwise_mutations
262
+ )
263
+
264
+ if predicate_matched
265
+ puts "All predicates matched"
266
+ end
267
+ ```
268
+
269
+ Do not use `check_and_mutate_row` if you are using an app profile that has
270
+ multi-cluster routing. (See
271
+ {Google::Cloud::Bigtable::AppProfile#routing_policy AppProfile#routing_policy}.)
272
+
273
+ ### Batch writes
274
+
275
+ You can write more than one row in a single RPC using
276
+ {Google::Cloud::Bigtable::Table#mutate_rows Table#mutate_rows}:
277
+
278
+ ```ruby
279
+ require "google/cloud/bigtable"
280
+
281
+ bigtable = Google::Cloud::Bigtable.new
282
+
283
+ table = bigtable.table("my-instance", "my-table")
284
+
285
+ entries = []
286
+ entries << table.new_mutation_entry("row-1").set_cell("cf1", "field1", "XYZ")
287
+ entries << table.new_mutation_entry("row-2").set_cell("cf1", "field1", "ABC")
288
+ responses = table.mutate_rows(entries)
289
+
290
+ responses.each do |response|
291
+ puts response.status.description
292
+ end
293
+ ```
294
+
295
+ Each entry in the request is atomic, but the request as a whole is not. As shown
296
+ above, Cloud Bigtable returns a list of responses corresponding to the entries.
297
+
298
+ ## Reading data
299
+
300
+ The {Google::Cloud::Bigtable::Table Table} class also enables you to read data.
301
+
302
+ Use {Google::Cloud::Bigtable::Table#read_row Table#read_row} to read a single
303
+ row by key:
304
+
305
+ ```ruby
306
+ require "google/cloud/bigtable"
307
+
308
+ bigtable = Google::Cloud::Bigtable.new
309
+ table = bigtable.table("my-instance", "my-table")
310
+
311
+ row = table.read_row("user-1")
312
+ ```
313
+
314
+ If desired, you can apply a filter:
315
+
316
+ ```ruby
317
+ require "google/cloud/bigtable"
318
+
319
+ bigtable = Google::Cloud::Bigtable.new
320
+ table = bigtable.table("my-instance", "my-table")
321
+
322
+ filter = Google::Cloud::Bigtable::RowFilter.cells_per_row(3)
323
+
324
+ row = table.read_row("user-1", filter: filter)
325
+ ```
326
+
327
+ For multiple rows, the
328
+ {Google::Cloud::Bigtable::Table#read_rows Table#read_rows} method streams back
329
+ the contents of all requested rows in key order:
330
+
331
+ ```ruby
332
+ require "google/cloud/bigtable"
333
+
334
+ bigtable = Google::Cloud::Bigtable.new
335
+ table = bigtable.table("my-instance", "my-table")
336
+
337
+ table.read_rows(keys: ["user-1", "user-2"]).each do |row|
338
+ puts row
339
+ end
340
+ ```
341
+
342
+ Instead of specifying individual keys (or a range), you can often just use a
343
+ filter:
344
+
345
+ ```ruby
346
+ require "google/cloud/bigtable"
347
+
348
+ bigtable = Google::Cloud::Bigtable.new
349
+ table = bigtable.table("my-instance", "my-table")
350
+
351
+ filter = table.filter.key("user-*")
352
+ # OR
353
+ # filter = Google::Cloud::Bigtable::RowFilter.key("user-*")
354
+
355
+ table.read_rows(filter: filter).each do |row|
356
+ puts row
357
+ end
358
+ ```
359
+
360
+ ## Deleting rows, tables, and instances
361
+
362
+ Use {Google::Cloud::Bigtable::Table#drop_row_range Table#drop_row_range} to
363
+ delete some or all of the rows in a table:
364
+
365
+ ```ruby
366
+ require "google/cloud/bigtable"
367
+
368
+ bigtable = Google::Cloud::Bigtable.new
369
+
370
+ table = bigtable.table("my-instance", "my-table")
371
+
372
+ # Delete rows using row key prefix.
373
+ table.drop_row_range(row_key_prefix: "user-100")
374
+
375
+ # Delete all data With timeout
376
+ table.drop_row_range(delete_all_data: true, timeout: 120) # 120 seconds.
377
+ ```
378
+
379
+ Delete tables and instances using
380
+ {Google::Cloud::Bigtable::Table#delete Table#delete} and
381
+ {Google::Cloud::Bigtable::Instance#delete Instance#delete}, respectively:
382
+
383
+ ```ruby
384
+ require "google/cloud/bigtable"
385
+
386
+ bigtable = Google::Cloud::Bigtable.new
387
+
388
+ instance = bigtable.instance("my-instance")
389
+ table = instance.table("my-table")
390
+
391
+ table.delete
392
+
393
+ instance.delete
394
+ ```
395
+
396
+ ## Additional information
397
+
398
+ Google Bigtable can be configured to use an emulator or to enable gRPC's
399
+ logging. To learn more, see the {file:EMULATOR.md Emulator guide} and
400
+ {file:LOGGING.md Logging guide}.
@@ -0,0 +1,31 @@
1
+ # Troubleshooting
2
+
3
+ ## Where can I get more help?
4
+
5
+ ### Ask the Community
6
+
7
+ If you have a question about how to use a Google Cloud client library in your
8
+ project or are stuck in the Developer's console and don't know where to turn,
9
+ it's possible your questions have already been addressed by the community.
10
+
11
+ First, check out the appropriate tags on StackOverflow:
12
+ - [`google-cloud-platform+ruby+bigtable`][so-ruby]
13
+
14
+ Next, try searching through the issues on GitHub:
15
+
16
+ - [`api:bigtable` issues][gh-search-ruby]
17
+
18
+ Still nothing?
19
+
20
+ ### Ask the Developers
21
+
22
+ If you're experiencing a bug with the code, or have an idea for how it can be
23
+ improved, *please* create a new issue on GitHub so we can talk about it.
24
+
25
+ - [New issue][gh-ruby]
26
+
27
+ [so-ruby]: http://stackoverflow.com/questions/tagged/google-cloud-platform+ruby+bigtable
28
+
29
+ [gh-search-ruby]: https://github.com/googleapis/google-cloud-ruby/issues?q=label%3A%22api%3A+bigtable%22
30
+
31
+ [gh-ruby]: https://github.com/googleapis/google-cloud-ruby/issues/new
@@ -0,0 +1,171 @@
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
+ # This file is here to be autorequired by bundler, so that the
17
+ # Google::Cloud#bigtable method can be available,
18
+ # but the library and all dependencies won't be loaded until required and used.
19
+
20
+ gem "google-cloud-core"
21
+
22
+ require "googleauth"
23
+ require "grpc"
24
+ require "google/cloud" unless defined? Google::Cloud.new
25
+ require "google/cloud/config"
26
+
27
+ module Google
28
+ module Cloud
29
+ ##
30
+ # Creates a new object for connecting to the Cloud Bigtable service.
31
+ #
32
+ # For more information on connecting to Google Cloud Platform, see the
33
+ # {file:AUTHENTICATION.md Authentication Guide}.
34
+ #
35
+ # @param scope [Array<String>]
36
+ # The OAuth 2.0 scopes controlling the set of resources and operations
37
+ # that the connection can access. See [Using OAuth 2.0 to Access Google
38
+ # APIs](https://developers.google.com/identity/protocols/OAuth2).
39
+ # The OAuth scopes for this service. This parameter is ignored if an
40
+ # updater_proc is supplied.
41
+ # @param timeout [Integer]
42
+ # The default timeout, in seconds, for calls made through this client.
43
+ # @param credentials [Google::Auth::Credentials, String, Hash, GRPC::Core::Channel,
44
+ # GRPC::Core::ChannelCredentials, Proc]
45
+ # Provides the means for authenticating requests made by the client. This parameter can
46
+ # be one of the following types.
47
+ # `Google::Auth::Credentials` uses the properties of its represented keyfile for
48
+ # authenticating requests made by this client.
49
+ # `String` will be treated as the path to the keyfile to use to construct
50
+ # credentials for this client.
51
+ # `Hash` will be treated as the contents of a keyfile to use to construct
52
+ # credentials for this client.
53
+ # `GRPC::Core::Channel` will be used to make calls through.
54
+ # `GRPC::Core::ChannelCredentials` will be used to set up the gRPC client. The channel credentials
55
+ # should already be composed with a `GRPC::Core::CallCredentials` object.
56
+ # `Proc` will be used as an updater_proc for the gRPC channel. The proc transforms the
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
+ # @return [Google::Cloud::Bigtable::Project]
64
+ #
65
+ # @example
66
+ # require "google/cloud/bigtable"
67
+ #
68
+ # gcloud = Google::Cloud.new
69
+ #
70
+ # bigtable = gcloud.bigtable
71
+ #
72
+ def bigtable scope: nil, timeout: nil, credentials: nil, client_config: nil
73
+ Google::Cloud.bigtable(
74
+ project_id: @project,
75
+ credentials: (credentials || @keyfile),
76
+ scope: scope,
77
+ timeout: (timeout || @timeout),
78
+ client_config: client_config
79
+ )
80
+ end
81
+
82
+ ##
83
+ # Creates a Cloud Bigtable client instance for data, table admin and instance admin
84
+ # operations.
85
+ #
86
+ # @param project_id [String]
87
+ # Project identifier for the Bigtable service you
88
+ # are connecting to. If not present, the default project for the
89
+ # credentials is used.
90
+ # @param credentials [Google::Auth::Credentials, String, Hash, GRPC::Core::Channel,
91
+ # GRPC::Core::ChannelCredentials, Proc]
92
+ # The means for authenticating requests made by the client. This parameter can
93
+ # be one of the following types.
94
+ # `Google::Auth::Credentials` uses the properties of its represented keyfile for
95
+ # authenticating requests made by this client.
96
+ # `String` will be treated as the path to the keyfile to use to construct
97
+ # credentials for this client.
98
+ # `Hash` will be treated as the contents of a keyfile to use to construct
99
+ # credentials for this client.
100
+ # `GRPC::Core::Channel` will be used to make calls through.
101
+ # `GRPC::Core::ChannelCredentials` will be used to set up the gRPC client. The channel credentials
102
+ # should already be composed with a `GRPC::Core::CallCredentials` object.
103
+ # `Proc` will be used as an updater_proc for the gRPC channel. The proc transforms the
104
+ # metadata for requests, generally, to give OAuth credentials.
105
+ # @param scope [Array<String>]
106
+ # The OAuth 2.0 scopes controlling the set of resources and operations
107
+ # that the connection can access. See [Using OAuth 2.0 to Access Google
108
+ # APIs](https://developers.google.com/identity/protocols/OAuth2).
109
+ # The OAuth scopes for this service. This parameter is ignored if an
110
+ # updater_proc is supplied.
111
+ # @param timeout [Integer]
112
+ # 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
+ # @return [Google::Cloud::Bigtable::Project]
119
+ #
120
+ # @example
121
+ # require "google/cloud/bigtable"
122
+ #
123
+ # bigtable = Google::Cloud.bigtable
124
+ #
125
+ def self.bigtable project_id: nil, credentials: nil, scope: nil, timeout: nil, client_config: nil
126
+ require "google/cloud/bigtable"
127
+ Google::Cloud::Bigtable.new(
128
+ project_id: project_id,
129
+ credentials: credentials,
130
+ scope: scope,
131
+ timeout: timeout,
132
+ client_config: client_config
133
+ )
134
+ end
135
+ end
136
+ end
137
+
138
+ # Sets the default Bigtable configuration
139
+ Google::Cloud.configure.add_config! :bigtable do |config|
140
+ default_project = Google::Cloud::Config.deferred do
141
+ ENV["BIGTABLE_PROJECT"]
142
+ end
143
+ default_creds = Google::Cloud::Config.deferred do
144
+ Google::Cloud::Config.credentials_from_env(
145
+ "BIGTABLE_CREDENTIALS", "BIGTABLE_CREDENTIALS_JSON",
146
+ "BIGTABLE_KEYFILE", "BIGTABLE_KEYFILE_JSON"
147
+ )
148
+ end
149
+ default_emulator = Google::Cloud::Config.deferred do
150
+ ENV["BIGTABLE_EMULATOR_HOST"]
151
+ end
152
+
153
+ config.add_field! :project_id, default_project, match: String, allow_nil: true
154
+ config.add_alias! :project, :project_id
155
+ config.add_field! :credentials, default_creds,
156
+ match: [
157
+ String,
158
+ Hash,
159
+ Google::Auth::Credentials,
160
+ GRPC::Core::Channel,
161
+ GRPC::Core::ChannelCredentials,
162
+ Proc
163
+ ],
164
+ allow_nil: true
165
+ config.add_field! :scope, nil, match: [String, Array]
166
+ config.add_field! :timeout, nil, match: Integer
167
+ config.add_field! :client_config, nil, match: Hash
168
+ config.add_field! :emulator_host, default_emulator,
169
+ match: String, allow_nil: true
170
+ config.add_field! :endpoint, nil, match: String
171
+ end