kura 0.2.31 → 0.2.32

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5d41f23004b441572f536da653b967f335c6a227
4
- data.tar.gz: cf69d83395e3ba989d7eec303743bb3159e0e0dd
3
+ metadata.gz: '08d7f0e191048d4a6127fd52dab6a7204b770a61'
4
+ data.tar.gz: 81634467b7efe23243d040f5776f75baf04a3f02
5
5
  SHA512:
6
- metadata.gz: 03011f8e8556bea60fadb20f4869ba8e12540dfdfb082d2cb1b59a78dae0c9a89a308c5d18458a19eaf2c461183c9e7b5e983819974e13b845790324101e0edc
7
- data.tar.gz: 6c8b48938633ba00da067eca51e6e14df0d5c80b8e9c8028ce56a7e542d7063c0cd1504e1f430bb01cfaa9d3fcc85697ab6bd5f494a4e172a03a78b96a6c02f2
6
+ metadata.gz: 58d30c4cd23c54205ae1ad972855e18730072ef31e3634771263762c2118e9126cd934ef03262e0df83b1644cf094cf93517f0f4ad1d126090f39908fbb7f17c
7
+ data.tar.gz: 6f08ec71cdb9fd3969d9149ed1edf26c52dd53bc81fa828b0b952d5f750fa8400dd2354884330957a77f095d4d6b27538a3d01e64dc589e52b43978ad8d7e6b2
data/ChangeLog.md CHANGED
@@ -1,3 +1,10 @@
1
+ # 0.2.32
2
+
3
+ ## Enhancements
4
+
5
+ * Support `external_data_configuration` option.
6
+ * Add `scope` keyword argument to Kura::Client.new.
7
+
1
8
  # 0.2.31
2
9
 
3
10
  ## Enhancements
data/README.md CHANGED
@@ -34,6 +34,9 @@ client = Kura.client(JSON.parse(File.read(json_file_path)))
34
34
 
35
35
  # b. With GCE bigquery scope (Only available on Google Compute Engine instance)
36
36
  client = Kura.client
37
+
38
+ # c. With External Data Sources. For example, accessing data hosted within Google Drive requires an additional OAuth scope.
39
+ client = Kura.client(.., scope: "https://www.googleapis.com/auth/drive")
37
40
  ```
38
41
 
39
42
  ### Job API
@@ -49,6 +52,7 @@ client.copy("src_dataset", "src_table", "dest_dataset", "dest_table", wait: 120)
49
52
 
50
53
  Bug reports and pull requests are welcome on GitHub at https://github.com/nagachika/kura.
51
54
 
55
+ > Memo: If run to google sheets testing requires environment variable `ENV['GOOGLE_SHEETS_FILE_URL']`.
52
56
 
53
57
  ## License
54
58
 
data/lib/kura.rb CHANGED
@@ -43,7 +43,7 @@ module Kura
43
43
  # Kura.client(gcp_project_id, email_address, prm_file_contents)
44
44
  # Kura.client(gcp_project_id, email_address, private_key_object)
45
45
  #
46
- def self.client(project_id=nil, email_address=nil, private_key=nil, http_options: {timeout: 60})
46
+ def self.client(project_id=nil, email_address=nil, private_key=nil, scope: nil, http_options: {timeout: 60})
47
47
  if email_address.nil? and private_key.nil?
48
48
  if project_id.is_a?(String)
49
49
  credential = JSON.parse(File.binread(project_id))
@@ -58,6 +58,6 @@ module Kura
58
58
  elsif private_key
59
59
  private_key = get_private_key(private_key)
60
60
  end
61
- self::Client.new(default_project_id: project_id, email_address: email_address, private_key: private_key, http_options: http_options)
61
+ self::Client.new(default_project_id: project_id, email_address: email_address, private_key: private_key, scope: scope, http_options: http_options)
62
62
  end
63
63
  end
data/lib/kura/client.rb CHANGED
@@ -8,9 +8,9 @@ require "kura/extensions"
8
8
 
9
9
  module Kura
10
10
  class Client
11
- def initialize(default_project_id: nil, email_address: nil, private_key: nil, http_options: {timeout: 60}, default_retries: 5)
11
+ def initialize(default_project_id: nil, email_address: nil, private_key: nil, scope: nil, http_options: {timeout: 60}, default_retries: 5)
12
12
  @default_project_id = default_project_id
13
- @scope = "https://www.googleapis.com/auth/bigquery"
13
+ @scope = ["https://www.googleapis.com/auth/bigquery"] | (scope ? scope.is_a?(Array) ? scope : [scope] : [])
14
14
  @email_address = email_address
15
15
  @private_key = private_key
16
16
  if @email_address and @private_key
@@ -24,7 +24,7 @@ module Kura
24
24
  Faraday.default_connection.options.timeout = 60
25
25
  auth.fetch_access_token!
26
26
  else
27
- auth = Google::Auth.get_application_default([@scope])
27
+ auth = Google::Auth.get_application_default(@scope)
28
28
  auth.fetch_access_token!
29
29
  end
30
30
  Google::Apis::RequestOptions.default.retries = default_retries
@@ -378,6 +378,7 @@ module Kura
378
378
  use_legacy_sql: true,
379
379
  maximum_billing_tier: nil,
380
380
  maximum_bytes_billed: nil,
381
+ external_data_configuration: nil,
381
382
  project_id: @default_project_id,
382
383
  job_project_id: @default_project_id,
383
384
  job_id: nil,
@@ -420,6 +421,9 @@ module Kura
420
421
  end
421
422
  end
422
423
  end
424
+ if external_data_configuration
425
+ configuration.query.table_definitions = external_data_configuration
426
+ end
423
427
  insert_job(configuration, wait: wait, job_id: job_id, project_id: job_project_id, &blk)
424
428
  end
425
429
 
data/lib/kura/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Kura
2
- VERSION = "0.2.31"
2
+ VERSION = "0.2.32"
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.31
4
+ version: 0.2.32
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chikanaga Tomoyuki
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-12-05 00:00:00.000000000 Z
11
+ date: 2018-05-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: google-api-client
@@ -149,7 +149,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
149
149
  version: '0'
150
150
  requirements: []
151
151
  rubyforge_project:
152
- rubygems_version: 2.6.13
152
+ rubygems_version: 2.6.14.1
153
153
  signing_key:
154
154
  specification_version: 4
155
155
  summary: Interface to BigQuery API v2.