kura 0.1.3 → 0.1.4

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: 80adcab6f4a5fd5ed60452a26121bbc13ecd491a
4
- data.tar.gz: 51431b6a1f57e9f01615b3af4b513652c155aeed
3
+ metadata.gz: a5efd73150912195d0d14025754f547070a7330d
4
+ data.tar.gz: 493c0f054490460710146625b8e8f47b23630579
5
5
  SHA512:
6
- metadata.gz: 77490104632b871a6f15f2ff034263b1a45379ca07a5412c6c83556c4a6993bea17f172c885e02201faa466068872d10c0d8d788d2056d1f54fa523cf98ead0f
7
- data.tar.gz: 0246eb96056d65d30e7b2473640d06ca713936725bd5350d607340be2e09afda189e85cc7f0b23aa37e07514f1bbb2b2e1588500e9cdf050cf72f38737d824c7
6
+ metadata.gz: 622bd7e0574fd825dda7e0611c4c5f055415f96f813d704f046f3d70c840ac91b927348de9cba7640d386dac7c47ec9063e262bfe532036190bdcc7912e9382e
7
+ data.tar.gz: fdc9fa61e501ef6247486b9040c8e6a3904ea2c805ed9820e6e5898b0c666de1ce13dd17c33953e00d67e5105e1e2c1e8f03198578e780d3079ea1f02de32f4b
data/ChangeLog.md CHANGED
@@ -1,3 +1,9 @@
1
+ # 0.2.0
2
+
3
+ ## Enhancements
4
+
5
+ * Support authentication with GCE bigquery scope.
6
+
1
7
  # 0.1.3
2
8
 
3
9
  ## Enhancements
data/README.md CHANGED
@@ -21,11 +21,23 @@ Or install it yourself as:
21
21
 
22
22
  ## Usage
23
23
 
24
+ ### Initialize
25
+
24
26
  ```
27
+ # a. With Service Account Private Key
25
28
  client = Kura.client(project_id, email, private_key)
29
+
30
+ # b. With GCE bigquery scope (Only available on Google Compute Engine instance)
31
+ client = Kura.client
32
+ ```
33
+
34
+ ### Job API
35
+
36
+ ```
26
37
  client.load("dataset", "table", "gs://mybucket/data.csv", wait: 120)
27
- client.query("SELECT * FROM [dataset.table];", wait: 120)
38
+ client.query("SELECT * FROM [dataset.table];", dataset_id: "dest_dataset", table_id: dest_table", wait: 120)
28
39
  client.extract("dataset", "result", "gs://mybucket/extracted.csv", wait: 120)
40
+ client.copy("src_dataset", "src_table", "dest_dataset", "dest_table", wait: 120)
29
41
  ```
30
42
 
31
43
  ## Contributing
data/lib/kura/client.rb CHANGED
@@ -5,17 +5,21 @@ require "kura/version"
5
5
 
6
6
  module Kura
7
7
  class Client
8
- def initialize(project_id, email_address, private_key)
9
- @default_project_id = project_id
8
+ def initialize(default_project_id: nil, email_address: nil, private_key: nil)
9
+ @default_project_id = default_project_id
10
10
  @scope = "https://www.googleapis.com/auth/bigquery"
11
11
  @email_address = email_address
12
12
  @private_key = private_key
13
- auth = Signet::OAuth2::Client.new(
14
- token_credential_uri: "https://accounts.google.com/o/oauth2/token",
15
- audience: "https://accounts.google.com/o/oauth2/token",
16
- scope: @scope,
17
- issuer: @email_address,
18
- signing_key: @private_key)
13
+ if @email_address and @private_key
14
+ auth = Signet::OAuth2::Client.new(
15
+ token_credential_uri: "https://accounts.google.com/o/oauth2/token",
16
+ audience: "https://accounts.google.com/o/oauth2/token",
17
+ scope: @scope,
18
+ issuer: @email_address,
19
+ signing_key: @private_key)
20
+ else
21
+ auth = Google::APIClient::ComputeServiceAccount.new
22
+ end
19
23
  @api = Google::APIClient.new(application_name: "Kura", application_version: Kura::VERSION, authorization: auth)
20
24
  @api.authorization.fetch_access_token!
21
25
  @bigquery_api = @api.discovered_api("bigquery", "v2")
data/lib/kura/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Kura
2
- VERSION = "0.1.3"
2
+ VERSION = "0.1.4"
3
3
  end
data/lib/kura.rb CHANGED
@@ -34,8 +34,10 @@ module Kura
34
34
  private_key
35
35
  end
36
36
 
37
- def self.client(project_id, email_address, private_key)
38
- private_key = get_private_key(private_key)
39
- self::Client.new(project_id, email_address, private_key)
37
+ def self.client(project_id=nil, email_address=nil, private_key=nil)
38
+ if private_key
39
+ private_key = get_private_key(private_key)
40
+ end
41
+ self::Client.new(default_project_id: project_id, email_address: email_address, private_key: private_key)
40
42
  end
41
43
  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.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chikanaga Tomoyuki
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-07-31 00:00:00.000000000 Z
11
+ date: 2015-08-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: google-api-client