kura 0.2.10 → 0.2.11

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0d400e0474997388a32379c30b147c49e605d1ce
4
- data.tar.gz: 8f9fed80311d1fe064c4d248c717cf838ed27e65
3
+ metadata.gz: 21bc7162d31e2dbf76656f90c3d69db812c7d8aa
4
+ data.tar.gz: d6f21b718169fb247c0a243ec49d8408b2ba4788
5
5
  SHA512:
6
- metadata.gz: 40f568b3e3cc682e56a8396f746d03b3ee9f97f1a80f7bec8ba1fbc4071dbd08392d812061aa6069eda25a8a0e22b5655613a63740597895389ab5330b663146
7
- data.tar.gz: fd0ec90c109a0dff8c6a61e72cc6f24eb62eba1e19c5451c98d41c988f4df4257654ace3534c5f4eda546581990e5e65795a2b5c8dba89b6b70ec39981e2a84e
6
+ metadata.gz: 378a26e155f0acf77dc400e6baed0866dabafec76cebf5b85cc8ca3e089d3dabf491f1b983a324425d58261895bcc34e8ee9fc4af1152e15af8298b4ea64dfca
7
+ data.tar.gz: 396bc763df427fcd9e29cd8991f38cc92740d189d16d16ada211497ddf858b9eb5c7b6d1673e088fdaa44a2881ff7cddf66f98c1c1f2f7fdcd065d93d2c3d651
data/ChangeLog.md CHANGED
@@ -1,3 +1,9 @@
1
+ # 0.2.11
2
+
3
+ ## Enhancements
4
+
5
+ * Add Kura::Client#insert\_tabledata. This is wrapper for tabledata.insertAll.
6
+
1
7
  # 0.2.10
2
8
 
3
9
  # Fixes
data/lib/kura/client.rb CHANGED
@@ -253,6 +253,36 @@ module Kura
253
253
  process_error($!)
254
254
  end
255
255
 
256
+ def insert_tabledata(dataset_id, table_id, rows, project_id: @default_project_id, ignore_unknown_values: false, skip_invalid_rows: false, template_suffix: nil)
257
+ request = Google::Apis::BigqueryV2::InsertAllTableDataRequest.new
258
+ request.ignore_unknown_values = ignore_unknown_values
259
+ request.skip_invalid_rows = skip_invalid_rows
260
+ if template_suffix
261
+ request.template_suffix = template_suffix
262
+ end
263
+ request.rows = rows.map do |r|
264
+ case r
265
+ when Google::Apis::BigqueryV2::InsertAllTableDataRequest::Row
266
+ r
267
+ when Hash
268
+ row = Google::Apis::BigqueryV2::InsertAllTableDataRequest::Row.new
269
+ if r.keys.map(&:to_s) == %w{ insert_id json }
270
+ row.insert_id = r[:insert_id] || r["insert_id"]
271
+ row.json = r[:json] || r["json"]
272
+ else
273
+ row.json = r
274
+ end
275
+ row
276
+ else
277
+ raise ArgumentError, "invalid row for BigQuery tabledata.insertAll #{r.inspect}"
278
+ end
279
+ end
280
+
281
+ r = @api.insert_all_table_data(project_id, dataset_id, table_id, request)
282
+ rescue
283
+ process_error($!)
284
+ end
285
+
256
286
  def mode_to_write_disposition(mode)
257
287
  unless %i{ append truncate empty }.include?(mode)
258
288
  raise "mode option should be one of :append, :truncate, :empty but #{mode}"
data/lib/kura/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Kura
2
- VERSION = "0.2.10"
2
+ VERSION = "0.2.11"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kura
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.10
4
+ version: 0.2.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chikanaga Tomoyuki
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-02-19 00:00:00.000000000 Z
11
+ date: 2016-03-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: google-api-client